facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
228.87k stars 46.82k forks source link

Bug: Firefox Android not triggering onSelect in <input> when dragging cursor #25643

Closed AndreasBBS closed 6 months ago

AndreasBBS commented 1 year ago

React version:

Steps To Reproduce

  1. Open the codepen linked below in Firefox on Android ( I suspect it's also a bug in Iphone but cannot confirm)
  2. Write some text in the text input
  3. Drag the cursor
  4. Notice that the event is not triggered when the cursor is dragged

Link to code example: https://codepen.io/AndreasBBS/pen/ExRgdgN (codesandbox was down at the moment I was testing this)

The current behavior

Firefox:

https://user-images.githubusercontent.com/12399440/200215567-0f785f12-017b-41a9-bacf-fce3ffe8e46a.mp4

The expected behavior

Chrome/Brave:

https://user-images.githubusercontent.com/12399440/200215632-8ded87ff-cda8-44f9-b3f6-c00848425869.mp4

Extra Details

This seems to have to do with how Firefox implements the selectionchange event for inputs. According to this documentation, firefox fires the selectionchange event on the input node instead of on document. In fact, if you try the little snippet they have in the documentation you'll find that it only works on Firefox and not any other browser. I'm not sure if other browsers are gonna move in this direction, but if they do, this bug will become more common. Chrome already has a bug report and if they 'fix' it, this behavior will also happen there.

AndreasBBS commented 1 year ago

I believe something in here needs to be changed. There's a comment saying:

    // Firefox doesn't support selectionchange, so check selection status
    // after each key entry. The selection changes after keydown and before
    // keyup, but we check on keydown as well in the case of holding down a
    // key, when multiple keydown events are fired but only one keyup is.
    // This is also our approach for IE handling, for the reason above.

But according to Firefox documentation it's not true: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/selectionchange_event

AndreasBBS commented 1 year ago

I've been trying to fix this and I can't get the event triggered on the input node to even reach the SelectEventPlugin.js @gaearon @kassens Sorry to bother but I noticed that you've been involved in the implementation of this plugin. Could you give me some directions on how you think that conceptually I could integrate the behavior supported by Firefox into this plugin?

github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] commented 6 months ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!