Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typeahead prevents focus callbacks #7269

Closed
cthielen opened this issue Mar 13, 2013 · 4 comments
Closed

Typeahead prevents focus callbacks #7269

cthielen opened this issue Mar 13, 2013 · 4 comments
Labels

Comments

@cthielen
Copy link

I'd like to select all text when a typeahead field is focused but Bootstrap is currently preventing this in both 2.x and 3.0.

The UX theory is that if typeahead makes it easy to search through lists by typing, the user may want to make changes just as quickly and we should be able to $.select() the text on focus to automatically erase the field's contents when they type something new.

This isn't good default behavior, but I don't know the use case for Typeahead to block focus events.

@pickypg
Copy link
Contributor

pickypg commented Mar 15, 2013

@cthielen I agree that the behavior should be overridable using the passed in options, but you can override it directly.

var typeahead = control.typeahead({ /* ... */}).data('typeahead');
control.off('focus').on('focus', function() {
    control.select();
    // maintain current behavior
    typeahead.focused = true;
});

@cthielen
Copy link
Author

I'm not sure that works: http://jsfiddle.net/tUbXL/

@pickypg
Copy link
Contributor

pickypg commented Mar 26, 2013

Interesting. I hadn't tested my example, although the jsfiddle seems to work in IE10, but not in Chrome when clicking directly; it works in Chrome if you add some source elements and select one of them. If you can figure out how to get Chrome to stop moving the cursor to the end (none of the event calls seemed to work), then the example can be modified to work appropriately.

On a related note, even when it is working, the behavior feels odd to me. Ignoring my feelings on the feature, I agree that focus, among most of the other functions, should be more easily overridable. I even made a pull request for such a feature that also adds support for using objects in Typeahead (#7298).

@mdo
Copy link
Member

mdo commented May 9, 2013

Punting on this.

We've dropped bootstrap-typeahead.js in v3 (see 88dd9de) in favor of folks using Twitter's typeahead.

<3

@mdo mdo closed this as completed May 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants