Skip to content

Fix silent failures of Alt+O / Alt+C shortcuts - #2721

Open
dream-creator wants to merge 1 commit into
freeCodeCamp:mainfrom
dream-creator:fix/alt-shortcuts-silent-failure
Open

Fix silent failures of Alt+O / Alt+C shortcuts#2721
dream-creator wants to merge 1 commit into
freeCodeCamp:mainfrom
dream-creator:fix/alt-shortcuts-silent-failure

Conversation

@dream-creator

@dream-creator dream-creator commented Aug 23, 2026

Copy link
Copy Markdown

Fixes #2634

What this PR does

Alt+O (open original page) and Alt+C (copy original link) currently fail completely silently when the rendered entry has no ._attribution ._attribution-link element, and Alt+C additionally had a leftover console.log and ignored clipboard promise rejections. This PR shows a transient notice when the link is unavailable, surfaces clipboard failures instead of swallowing them, and removes the debug logging.

Investigation notes

While debugging why the shortcuts "do nothing" for some users and work for others:

  • The cached entry data on documents.devdocs.io does contain the _attribution block (verified against e.g. git-status.html), so the selector input exists at the data level.
  • The failure mode is therefore environment- or page-dependent (stale service-worker caches serving pre-attribution HTML, docs whose scrapers render no attribution, or pages where attribution isn't the last child) — exactly the split reported in the issue (works on some macOS setups, dead on Windows/others).
  • Because both handlers bailed out with a bare return, every one of those cases produced identical "nothing happens" behavior, making the bug impossible to self-diagnose from the UI. Surfacing a notice turns the invisible state into actionable feedback.

Changes

  • entry_page.js: both handlers now show a transient notice ("The original page link is not available for this documentation") instead of silently returning; onAltC handles the navigator.clipboard.writeText rejection with its own notice; removed stray console.log
  • notice_tmpl.js: added noOriginalLinkNotice and copyFailedNotice templates following the existing pattern
  • New notices auto-dismiss after 3 seconds and replace each other rather than stacking

Testing

DevDocs has no JS unit-test infrastructure yet (#2673), so verification was: syntax check on both modified files plus manual code-path review against the cached-entry structure linked above. The notice path can be exercised by running any entry whose scraped HTML lacks an attribution block.

Happy to iterate if maintainers would prefer different wording/behavior (e.g. also attempting URL reconstruction for docs without attribution).

Alt+O (open original page) and Alt+C (copy original link) both bail out
silently when the rendered entry has no ._attribution ._attribution-link
element, which left users of affected documentations with dead shortcuts
and no feedback (freeCodeCamp#2634). Alt+C also logged to console on every use and
ignored clipboard promise rejections after the navigator.clipboard
migration.

- Show a transient notice when no original-page link exists
- Surface a notice if the clipboard write rejects instead of failing
  silently; drop the leftover console.log
- Notices auto-dismiss after 3s without stacking
@dream-creator
dream-creator requested a review from a team as a code owner August 23, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alt+O and Alt+C keyboard shortcuts are no longer working

1 participant