xcash / bootstrap-autocomplete

Bootstrap Autocomplete
MIT License
168 stars 72 forks source link

TAB keyup should be ignored/not trigger ajax request & dropdown #114

Open micschk opened 3 years ago

micschk commented 3 years ago

Currently when using the tab-key to cycle through form-fields, upon focussing on an autocomplete-field which already has a value, the TAB keyup event on that field will trigger the ajax call & dropdown for that field.

IMO autocomplete should not be triggered by a TAB keyup as that's typically used to jump from one field to another.

xcash commented 3 years ago

TAB confirms the item selected in the autocomplete. I need to investigate these edge cases to prevent some bad behavior.

machinehum commented 3 years ago

This isn't related to TAB confirming the item selected in the autocomplete. This is TAB triggering handlerTyped (via falling through to the 'default' in the keyUp switch statement around line 250) when the user tabs into or out of an input, which fundamentally breaks the behavior of html forms (and is also very bad for accessibility). The user does not expect a search to happen and a dropdown to show up for a field they've already tabbed away from, or for a search to happen on the extant value for a field that they tab into.

You just need to add a 'case 9:' with no action in the 'switch' that starts on line 252 in main.ts. Tested this locally and confirmed it fixes this issue and does not affect the dropdown.

machinehum commented 3 years ago

Pull request opened (128).