-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Android: Firefox and Chrome TextInput onSelectionChange events differ #2422
Comments
This seems to be a Firefox Android bug based on what is said here Expensify/App#12298 |
@necolas I found this out: Expensify/App#12298 (comment) It looks to me that the Firefox engine does approach this selection issue but in a different way than the Chrome engine. How does this library normalize across different engines behaviors? |
The onSelectionChange in the TextInput component is listening to the event 'selectionchange' on Document. Firefox is the only browser that seems to implement correctly the behavior where the 'selectionchange' event is triggered on the input element. There is already a bug opened on chrome for this: https://bugs.chromium.org/p/chromium/issues/detail?id=1327098 You can also see here that the list of browsers with compatibility for this feature is currently only Firefox but as more browsers adopt it this bug will only become more common. |
@necolas I've been digging deeper on this bug and I found out that this extends to React. I took a look at this package code and found out that onSelectionChange handler is simply passed to the input's onSelect which is handled by React. I tested this behavior with React's onSelect and figured out it also happens there. I opened this issue in case you're interested in following this. I think nothing needs to be changed in this lib, it does the right thing, it's React that needs to handle the onSelect situation better. I'm closing this issue. Sorry for wasting your time, I should have investigated this better before opening this. |
Thanks for all the investigation. I'd like to keep this open because we could still implement a fix using native event listeners instead of React DOM's event disturb |
Is there an existing issue for this?
Describe the issue
Using a TextInput in Firefox on Android, when the cursor is dragged, the onSelectionChange is not triggered with the new selection values.
Chrome/Brave:
Record_2022-11-06-19-10-32.mp4
Firefox:
Record_2022-11-06-19-12-04.mp4
Expected behavior
I expect Firefox to behave the same as Chrome
Steps to reproduce
NPM versions:
react: 17.0.*
react-dom: 17.0.*
react-native-web: 0.18.*
Browser:
Firefox for Android
The codebox example I'm attaching makes it really easy to test this phenomenom
Test case
https://codesandbox.io/s/icy-pine-5tbtxj
Additional comments
No response
The text was updated successfully, but these errors were encountered: