Skip to content

Fix double click selection issues for heading with a clickable anchor link #3206

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HiDeoo
Copy link
Member

@HiDeoo HiDeoo commented May 21, 2025

Description

This PR is a follow-up to #3140.

This PR is a draft PR as I'd like to get some eyes on it with mutliple people testing it in multiple browsers during a Talking and Doc'ing session.

Turns out that the issue was not entirely fixed:

  • Use Chrome or Safari
  • Double click the last word (or single word for a heading with only 1 word) of a heading with a clickable anchor link
  • Copy the selected text

The clipboard will contain an extra new line character at the end of the copied text.

  • My initial fix in Astro Docs was also not entirely correct as the issue only happens when the anchor link is after the heading, but on larger displays, in Astro Docs, the anchor link is currently before the heading. To reproduce the issue in Astro Docs, you need to resize the window to make the anchor link appear after the heading.
  • My testing method was bad: I double clicked a word, copied it to my clipboard, pressed Cmd + T to open a new tab and focus the address bar, and pasted the text there. This is not a good test as the address bar will trim any trailing new line characters. To properly test this, I should have pasted the text in a text editor.

After quite a bit of trial and error, one of the solution I found was to change the display property of the link to inline-flex (inline-block does not work, don't ask me why) which should not have any side effects.

Copy link

changeset-bot bot commented May 21, 2025

⚠️ No Changeset found

Latest commit: 27e3d49

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented May 21, 2025

�� Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 27e3d49
🔍 Latest deploy log https://app.netlify.com/projects/astro-starlight/deploys/682dd57f2b834a000806b732
😎 Deploy Preview https://deploy-preview-3206--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the 🌟 core Changes to Starlight’s main package label May 21, 2025
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Chrome and Firefox (desktop, macOS) and can confirm that this PR fixes the issue

Copy link
Member

@ArmandPhilippot ArmandPhilippot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine for me both on Firefox and Chromium (with Manjaro Linux), so its looks like it's fixed! Good job! 🙌🏽 Tested both with double clicks and triple clicks.

@sarah11918
Copy link
Member

Working for me on Android Chrome mobile, and ChromeOS!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 core Changes to Starlight’s main package
4 participants