Fix silent failures of Alt+O / Alt+C shortcuts - #2721
Open
dream-creator wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-linkelement, and Alt+C additionally had a leftoverconsole.logand 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:
_attributionblock (verified against e.g. git-status.html), so the selector input exists at the data level.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;onAltChandles thenavigator.clipboard.writeTextrejection with its own notice; removed strayconsole.lognotice_tmpl.js: addednoOriginalLinkNoticeandcopyFailedNoticetemplates following the existing patternTesting
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).