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

Double/triple click headings copy issues #8001

Closed
HiDeoo opened this issue Apr 24, 2024 · 2 comments · Fixed by #8015
Closed

Double/triple click headings copy issues #8001

HiDeoo opened this issue Apr 24, 2024 · 2 comments · Fixed by #8015
Labels
bug Something on the site isn't working

Comments

@HiDeoo
Copy link
Member

HiDeoo commented Apr 24, 2024

📝 Issue Description

It looks like there may be some issues when copying headings when using either double click (select a word) or triple click (select a paragraph/logical unit). The behavior seems to be different depending on the browser and be related to heading anchor links.

Chrome

When the viewport width is less than 95em (the heading anchor link is at the end of the heading) and double clicking and copying a heading with a single word or the last word of a multiple words heading will inject Section in the clipboard text (I am assuming this is the first word of the heading anchor link screen reader text).

For example, going to this page and double clicking and copying the heading Features will copy FeaturesSection instead of Features. Double clicking and copying the word Principles in the heading Design Principles will copy PrinciplesSection instead of Principles.

Triple clicking is working as expected.

Firefox

When the viewport width is less than 95em (the heading anchor link is at the end of the heading) and triple clicking a heading and copying will inject the entire heading anchor link screen reader text in the clipboard text.

For example, going to this page and triple clicking and copying the heading Features will copy FeaturesSection titled Features instead of Features.

Safari

When the viewport width is less than 95em, double clicking or triple clicking a heading with a single word or the last word of a multiple words heading will visually select the entire page and copying will inject Section in the clipboard text too.

SCR-20240424-lddg

When the viewport width is greater than 95em, triple clicking a heading with a single word or the last word of a multiple words heading will visually select the entire page (the clipboard content is fine in this case).

📋 On which page(s) it occurs

I used https://docs.astro.build/en/concepts/why-astro/#features as an example but this can repro on every pages with headings.

🤔 Expected Behavior

The selection should visually match what is expected (either a word or an entire heading but never the entire page) and the copied text should match such selection and never contains invisible text.

👀 Current Behavior

The selection can be visually wrong and the copied text can include invisible text.

🖥️ Browser

Chrome 125.0.6422.4 - Firefox 125.0.2 - Safari 17.4.1

📄 Additional Information

No response

@HiDeoo HiDeoo added the bug Something on the site isn't working label Apr 24, 2024
@delucis
Copy link
Member

delucis commented Apr 25, 2024

Oh boy! Hadn’t noticed this before.

I wonder if there is some simple solution like a single space between the heading and the anchor link that would avoid the double click case.

I’m less sure about how to solve the triple click case. It surprises me a bit, because the markup is <h2>Heading</h2></a>Section link</a>, so the link is not even within the block heading element. I guess it might be because we use display: inline on the heading at the narrow breakpoint?

@HiDeoo
Copy link
Member Author

HiDeoo commented Apr 25, 2024

I wonder if there is some simple solution like a single space between the heading and the anchor link that would avoid the double click case.

This is one of the idea that I had but did not get the chance yet to actually test it and I wanted to have an issue listing all cases with all browsers so it's easier to test.

I'll report back after playing a bit with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something on the site isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants