fix(mobile): hide keyboard when scroll suggestions#15
Conversation
auto-complete.js
Outdated
| that.blurHandler = function (e) { | ||
| var isSuggestionsFocused = document.querySelector('.autocomplete-suggestions--focused'); | ||
| if (!isSuggestionsFocused) { | ||
| try { var over_sb = document.querySelector('.autocomplete-suggestions:hover'); } catch (e) { var over_sb = 0; } |
There was a problem hiding this comment.
querySelector returns null if element doesn't exist, use camelCase.
What does Sb mean?
| try { var over_sb = document.querySelector('.autocomplete-suggestions:hover'); } catch (e) { var over_sb = 0; } | |
| var overSb = document.querySelector('.autocomplete-suggestions:hover'); |
There was a problem hiding this comment.
It's strange, I prefer to not change the current codebase and use another patch to refactor entire code, including standard os JS used: lint, es6, etc
There was a problem hiding this comment.
I think Sb means suggestions body, I really don't know 😭
| // create suggestions container "sc" | ||
| that.parentPositionDeterminant = getParentPositionDeterminant(that); | ||
| that.sc = document.createElement('div'); | ||
| that.sc.setAttribute('tabindex', '-1'); |
There was a problem hiding this comment.
This is weird, div by default can not be focused
There was a problem hiding this comment.
Yes, it's not common but acceptable, it was necessary in this case. I prefer to use -1 to not be a focusable element by user, just using code.
Another approach to remove focus from autocomplete input was to include some input element inside autocomplete-suggestions div, but I think it's more weird than first one.
Problem: when scroll suggestions, the keyboard keeps opened as following gif below. This patch fixes this behavior, passing to focus on suggestion items.