Skip to content
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

Prevent i beam on safari if userSelect is none #2381

Closed

Conversation

jatinsonijs
Copy link

@jatinsonijs jatinsonijs commented Jan 17, 2023

Description

Safari use I-Beam cursor on drag on most of the elements, exclude some native element like button, anchor tag etc...
We are using gesture on div that's way safari show I-Beam cursor on drag.
We already have userSelect prop which we can use to prevent text select. This PR extending the use of userSelect prop, if userSelect is none prevent safari default behaviour to show I-Beam cursor on drag.

As indicate in Safari webkit source code:
https://github.com/WebKit/WebKit/blob/3c53378a77e57141a3b53f344e4bc1c14f7cef39/Source/WebCore/page/EventHandler.cpp#L1553

@s77rt
Copy link

s77rt commented Jan 17, 2023

As stated in my PR here #2359
We should not couple the onselectstart (JS) with uset-select (CSS) as they are not the same thing and do not behave the same way, doing so will cause a regression throughout the entire application. Instead we should use an explicit prop that the user can opt for so he knows what to expect.

Consider this example:

<!DOCTYPE html>
<html>
<body>
<div id="a" style="user-select: none">
	<span>text inside a</span>
    <div id="b" style="user-select: text">
        <span>text inside b</span>
    </div>
</div>
</body>
</html>
  • You can't select text a
  • But you can select text b

Now if execute this code:
document.querySelector('#a').onselectstart = () => false;

  • You won't be able to select any <-- the regression

@jatinsonijs
Copy link
Author

@s77rt same situation will also happen with disableSelection as we cannot override inner view to perform text selection.

Can you plz provide an example with Panhandler where userSelect: 'none' will not work but disableSelection will work

@s77rt
Copy link

s77rt commented Jan 17, 2023

@jatinsonijs Yes, same thing with disableSelection but the user would be aware of that. Your solution will apply that to every current implementation.

@s77rt
Copy link

s77rt commented Jan 17, 2023

@jatinsonijs Sorry, I have updated the example, using user-select: text now

@jatinsonijs jatinsonijs deleted the prevent-i-beam-on-safari branch January 17, 2023 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants