fix(onMouseMove): only call handler on non-touch devices #1571
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.
What:
Don't call the onMouseMove handler when a touch event is detected.
Why:
Not really needed, since on mobile we don't highlight items with touch.
It also causes a sequence of batched dispatch calls that are difficult to understand and, most probably, wrong.
On mobile, when touching to select an item, we had a couple of batched dispatch calls:
To me, it did not make sense. On non-mobile, it was fine, mouse move when mouse actually moved, and click after click. Nothing else.
Now we should only get itemClick on mobile when we touch to select an item.
Closes #1540.
Closes #1566.
Closes #1447.
It should also fix our example with Basic multiple selection. Once this PR will get merged, the example also needs to have the
selectedItem
passed asnull
, as the example already does not care about it since we keep the selectedItems as custom state. Passing selectedItem as null controlled prop will also make the onSelectedItemChange get called on successive item clicks.How:
Check if we have onTouchDown, and if so, don't call dispatch in the onMouseMove handler. We update the
useMouseAndTouchTracker
to provide us with the value.Also a few changes:
ControlledPropUpdatedSelectedItem
on first render, since we already get the proper selectedItem + input value combination in the initial state setup.Checklist: