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

CSS user-select none property not effective in Safari #1654

Closed
glenvan opened this issue Oct 16, 2023 · 2 comments · Fixed by #1655
Closed

CSS user-select none property not effective in Safari #1654

glenvan opened this issue Oct 16, 2023 · 2 comments · Fixed by #1655
Labels
bug Things that aren't working right in the library.

Comments

@glenvan
Copy link

glenvan commented Oct 16, 2023

Describe the bug

Shoelace uses user-select: none; to prevent users from accidentally selecting text inside of non-editable UI Components (buttons, tags, etc.). Safari, bafflingly, still doesn't recognize that property without the -webkit- prefix.

This is a bigger problem on the desktop than mobile as it's much easier to accidentally drag across widget text with a mouse than on a touch device.

Apple Webkit-based views also exhibit this behaviour.

To Reproduce

Steps to reproduce the behavior:

  1. Load any sample shoelace widget in Safari
  2. Click within the widget text and drag across the text
    • On mobile, a long-press would be equivalent
  3. Observe that the standard user-select: none; property is not effective, and text within the component is selected

Demo

UI components like with non-editable text that expect mouse interaction like <sl-button> are the most obvious thing to try.

Screenshots

image

Browser / OS

  • OS: macOS Sonoma 14.0
  • Browser: Safari
  • Browser version: 17.0

Additional information

It's fairly easy to work around this issues by adding -webkit-user-select: none; to Shoelace components in your app's own stylesheet, but of course you have to do your homework within Shoelace to find components that need it.

The fix is simple enough, just add a -webkit-user-select: none; fallback wherever user-select: none; appears in Shoelace's CSS.

@glenvan glenvan added the bug Things that aren't working right in the library. label Oct 16, 2023
@claviska
Copy link
Member

Thanks. TIL. Fixed in #1655.

@glenvan
Copy link
Author

glenvan commented Oct 16, 2023

Thanks. TIL. Fixed in #1655.

Thank you, that's record turnaround. Works a treat in Safari now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants