-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix double/triple click selection issues on headings #8015
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed on Firefox & Chrome. Thanks for tackling this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart fix! Also wonder if .sr-only
should always include user-select: none
, but I’m not 100% confident there as those are quite different semantically — maybe there’s some cases where text selection could make sense with visually hidden text, not sure.
Same, and even after talking with people having a better experience with this than me, the specificity of the selector seems like a wise choice for the time being. |
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com> Co-authored-by: Reuben Tier <64310361+TheOtterlord@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com> Co-authored-by: Reuben Tier <64310361+TheOtterlord@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com> Co-authored-by: Reuben Tier <64310361+TheOtterlord@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com> Co-authored-by: Reuben Tier <64310361+TheOtterlord@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Description (required)
This PR fixes some text selection issues when double or triple clicking headings.
A short summary of the issue would be that double/triple click selection on headings could include some extra content when copying the selection. Refer to #8001 for a detailed list of all the issues by browser as the behavior is different in each one and I don't think it is worth duplicating the information here.
The changes fixes all the issues at the same time. I tried various approaches before settling on this one:
A basic space does not fix the issue.
A zero-width space would fix the issue in Chrome and Firefox, but not in Safari. It also has the downside of adding a character, non-visible (and non-conventional) to the text which browsers may or may not include when copying the selected heading.
On top of that, some editors or note-taking apps may highlight such a character if the browser used includes it in the copied text.
For example, here is how it looks in my VS Code when copying the heading with a zero-width space (notice the yellow rectangle at the end of the heading):
The CSS approach used in this PR.
Accessiblity-wise, I couldn't think of any downside of using this approach in this specific case on this specific class (nor could I find any mention of this in my researches) and testing with VoiceOver and NVDA didn't show any change in behavior whatsoever.
For reference, here is a preview of the VoiceOver behavior before and after the change:
Related issues & labels (optional)