onClick isn't triggered for touch devices #364
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #363. To be tested on multiple devices here ... e.g. it should not trigger a click into a different input afterwards.
The onBlur-pointerDownOnSuggestion workaround is only necessary for onClick but not if we use onMouseDown And the onClick of AutocompleteEntry somehow isn't triggered for touch devices although it should - maybe the onBlur event is the problem here too. Regardless of this: if we use
onTouchStart={()=>onSelect()}
(or onTouchEnd) it seems works on touch devices too. i.e. we can fix the issue and remove the onBlur-pointerDownOnSuggestion workaround via using onPointerDown instead of onClick.Update: no. The UX is ugly when using onPointerDown as the finger is then still on the screen (or mouse is down) triggering wrong things like adding more locations (i.e. clicking elements underneath the autocomplete box). Using onPointerUp seems to avoid these problems and still provide a single working method for mouse+touch.
Update: We should use our old pointer-event-cancel method as it is less code. Somehow the "touch cancellation" does not work -> remove that for now (even less code).