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

Fix double/triple click selection issues on headings #8015

Merged
merged 2 commits into from May 1, 2024

Conversation

HiDeoo
Copy link
Member

@HiDeoo HiDeoo commented Apr 25, 2024

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):

    SCR-20240425-qbzi
  • 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:

headings-voiceover

Related issues & labels (optional)

Copy link

vercel bot commented Apr 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview May 1, 2024 2:28pm

@HiDeoo HiDeoo added bug Something on the site isn't working a11y Anything to do with improving accessibility labels Apr 25, 2024
Copy link
Member

@TheOtterlord TheOtterlord left a 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!

@sarah11918 sarah11918 added the site improvement Some thing that improves the website functionality - ask @delucis for help! label May 1, 2024
Copy link
Member

@delucis delucis left a 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.

@HiDeoo
Copy link
Member Author

HiDeoo commented May 1, 2024

Also wonder if .sr-only should always include user-select: none, but I’m not 100% confident

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.

@HiDeoo HiDeoo merged commit 52fd745 into withastro:main May 1, 2024
8 checks passed
@HiDeoo HiDeoo deleted the hd-fix-headings-selection branch May 1, 2024 14:29
wpplumber pushed a commit to wpplumber/astro-docs that referenced this pull request May 4, 2024
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>
wpplumber pushed a commit to wpplumber/astro-docs that referenced this pull request May 9, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Anything to do with improving accessibility bug Something on the site isn't working site improvement Some thing that improves the website functionality - ask @delucis for help!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Double/triple click headings copy issues
4 participants