You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(core/clipboard): keep copy buttons in saved documents and confirm a copy - #5529
Refs #3766 (Keep WebIDL copy button in exported documents), which I closed as by design. This reverses that: copy buttons on WebIDL and CDDL blocks now stay in saved documents. A copy that works shows a check and a "Copied!" bubble that fades out after 1.2 seconds, and screen readers announce "Copied!" too. A copy the clipboard refuses shows a "Could not copy!" bubble and is announced the same way, where it used to be an unhandled promise rejection. A click now copies once instead of twice. Pages served over plain http have no clipboard, so the button hides there. Claude wrote the change. Gemini wrote some of its tests and reviewed the rest.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Saved pages can retain stale confirmation state or hide available copy controls, overlapping timers can erase announcements, and buttons remain visible but nonfunctional without the runtime.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Clipboard feedback can be overwritten by stale writes, clicks can be blocked by stopped propagation, messages can appear off-screen, and active feedback can appear in print.
This listener only sees clicks that bubble all the way to document. If an author places an IDL or CDDL block inside an interactive container that calls stopPropagation(), the copy button no longer works; the previous listener on the button did. Register the delegated listener in the capture phase so it also handles those clicks.
Hide the entire copy button when printing
src/styles/clipboard.css.js:100
visibility: hidden on the button does not hide descendants that explicitly set visibility: visible. Printing while a confirmation is active can therefore print the check icon or the “Copied!”/failure bubble over the specification. Remove the entire button from print layout instead; the override must beat the more specific ready rule.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unresolved clipboard issues can leave buttons unusable in saved pages or documents with a form named “respec,” and can display stale or misleading confirmations.
No open issues 🎉
4 previously missed issues
In code that hasn't changed since last review
Avoid treating a named form as a ReSpec instance
src/core/clipboard.js:111
A document containing <form name="respec"> exposes that form as document.respec through HTML's named-property lookup. In the exported document this condition then skips the runtime, leaving every copy button hidden even though ReSpec is not running. Check for the actual ReSpec instance rather than just a truthy property.
Repeat stale confirmation cleanup after DOMContentLoaded
src/core/clipboard.js:158
The saved runtime can execute before every copy button has been parsed. An IDL block moved after the script by src/core/render-biblio.js can then retain a saved confirmation indefinitely when the page is reopened. Repeat this cleanup after DOMContentLoaded, while preserving copies started by the new runtime.
A browser-saved snapshot retains respec-copy-ready in its markup. If scripts are disabled or blocked by a content security policy, the copy buttons remain visible without a listener, and any saved confirmation can stay visible too. Gate visibility on non-serialized runtime state and add a scripts-blocked browser-snapshot test.
Keep failure label visible during fade-out
src/core/clipboard.js:246
When a copy fails, removing data-failed immediately switches the bubble's content back to data-copied-label, while the CSS keeps the bubble visible for its 0.4-second fade-out. Readers therefore briefly see “Copied!” after “Could not copy!”. Keep the failure label selected until the fade completes, independently of the attribute that starts the transition.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Browsers with clipboard support but without constructable or adopted stylesheets can throw before the saved runtime script is appended, blocking processing.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The fallback serializes its visibility rule into snapshots, leaving a nonfunctional copy button visible when scripts or the clipboard API are unavailable.
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
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.
Refs #3766 (Keep WebIDL copy button in exported documents), which I closed as by design. This reverses that: copy buttons on WebIDL and CDDL blocks now stay in saved documents. A copy that works shows a check and a "Copied!" bubble that fades out after 1.2 seconds, and screen readers announce "Copied!" too. A copy the clipboard refuses shows a "Could not copy!" bubble and is announced the same way, where it used to be an unhandled promise rejection. A click now copies once instead of twice. Pages served over plain http have no clipboard, so the button hides there. Claude wrote the change. Gemini wrote some of its tests and reviewed the rest.