Skip to content

fix(docs-infra): avoid copy button overlap in code blocks#69030

Merged
atscott merged 1 commit into
angular:mainfrom
KirtiRamchandani:fix/docs-code-copy-overlap
Jun 8, 2026
Merged

fix(docs-infra): avoid copy button overlap in code blocks#69030
atscott merged 1 commit into
angular:mainfrom
KirtiRamchandani:fix/docs-code-copy-overlap

Conversation

@KirtiRamchandani

@KirtiRamchandani KirtiRamchandani commented May 31, 2026

Copy link
Copy Markdown
Contributor

Problem

Code-block copy buttons on angular.dev are absolutely positioned over the scrollable code area. On narrow screens or horizontally scrollable examples, the button can cover source text.

Root cause

For code blocks with headers, the button is still positioned below the header, inside the code body, so horizontal scrolling can move code underneath the fixed button.

Solution

Move copy buttons for headered code blocks into the header area and reserve inline space in the header so the button does not overlap header text or code content.

Fixes #68534.

Tests

  • npx --yes [email protected] --check adev/shared-docs/styles/docs/_code.scss
  • npx --yes [email protected] --no-source-map adev/shared-docs/styles/docs/_code.scss
  • git diff --check

@pullapprove pullapprove Bot requested a review from josephperrott May 31, 2026 07:00
@angular-robot angular-robot Bot added the area: docs-infra Angular.dev application and infrastructure label May 31, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 31, 2026
@MeAkib

MeAkib commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Follow this #68537 (comment)

@KirtiRamchandani

Copy link
Copy Markdown
Contributor Author

Thanks for pointing me back to that direction. I pushed a follow-up that now reveals the copy button on hover/focus instead of keeping it always visible.

The update keeps keyboard access intact with :focus-within / :focus-visible, keeps success/failure states visible after activation, and applies the same behavior to example-viewer code panes as well as regular docs-code blocks.

Checks run:

px --yes [email protected] --check adev/shared-docs/styles/docs/_code.scss

px --yes [email protected] --no-source-map adev/shared-docs/styles/docs/_code.scss

  • git diff --check

The local pre-commit hook warned that the
g-dev formatting/commit-message helpers could not run, so I verified the touched SCSS directly with the commands above.

@KirtiRamchandani

Copy link
Copy Markdown
Contributor Author

Apologies, the hover/focus follow-up was not on this PR branch earlier. It is now pushed in 95efab6.

Reran the targeted checks:

  • npx --yes [email protected] --check adev/shared-docs/styles/docs/_code.scss
  • npx --yes [email protected] --no-source-map adev/shared-docs/styles/docs/_code.scss $env:TEMP\angular-code.css
  • git diff --check HEAD~1..HEAD

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Deployed adev-preview for bf7d9a6 to: https://ng-dev-previews-fw--pr-angular-angular-69030-adev-prev-8q9h6hjw.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

Reveal code copy controls on hover and focus so long code snippets stay readable while keyboard access and copy state feedback remain intact.
@KirtiRamchandani KirtiRamchandani force-pushed the fix/docs-code-copy-overlap branch from 95efab6 to bf7d9a6 Compare June 5, 2026 04:55
@KirtiRamchandani

Copy link
Copy Markdown
Contributor Author

Fixed the lint failure by rewriting the branch to a single commit with a valid Angular commit-message body (�f7d9a6198). Local check: git diff --check HEAD~1..HEAD passes. Waiting for CI to rerun.

@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jun 8, 2026
@JeanMeche JeanMeche removed the request for review from josephperrott June 8, 2026 18:39
@atscott atscott merged commit b7cb584 into angular:main Jun 8, 2026
26 checks passed
@atscott

atscott commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

erkamyaman added a commit to erkamyaman/angular-tr that referenced this pull request Jul 4, 2026
The "Prefer" / "Avoid" code block headers rendered the style label as
plain inline text joined to the title with a bare "-" separator, giving
the two block types little visual distinction. The taller label also left
the prefer/avoid header at a different height from the plain filename
header, so the copy button's single "top" value could not center it in
both.

Style the label as a small uppercased pill tinted with the block's style
color, drop the "-" separator, add a subtle inset accent under the header,
and swap the heavier "dangerous" icon on "Avoid" for "close". Give every
header a fixed height with box-sizing: border-box and vertically center
its contents so all variants render at the same height and the copy button
stays centered.

This supersedes angular#69638, folding in its centering fix for the copy button
offset that angular#69030 introduced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker adev: preview area: docs-infra Angular.dev application and infrastructure target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy button overlaps code content in code blocks on smaller screens

4 participants