Skip to content

Improve copying when the clipboard is blocked, and credit a contributor - #52

Merged
Gabriel Mongefranco (gabrielmongefranco) merged 2 commits into
mainfrom
fix/manual-copy-popup-text
Oct 27, 2026
Merged

Gabriel Mongefranco (gabrielmongefranco) merged 2 commits into
mainfrom
fix/manual-copy-popup-text

Conversation

@gabrielmongefranco

@gabrielmongefranco Gabriel Mongefranco (gabrielmongefranco) commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

This follows up on #51, which added a popup for copying text by hand when the browser refuses to copy.

Changes

  • Older copy command before the popup. Some pages block the browser's clipboard feature or don't offer it at all, such as pages opened over plain http. The browser's older copy command (document.execCommand('copy')) often still works there. Copy buttons now try it, using a hidden text box that is removed right away, before they show the popup. Fewer people should see the popup as a result. Browsers have deprecated this command, but all major browsers still support it, and the popup is still there if it fails.
  • Focus. After the older copy command, keyboard focus goes back to the control that started the copy, if that control is still on the page. The question popup (dlvAskDialog) makes the same check.
  • Clearer message. The popup said "The text could not be copied. Select the text below, then copy it using your device." It now says "Your browser didn't allow copying. The text below is selected, so press Ctrl+C to copy it (Cmd+C on a Mac)." The text is already selected when the popup opens, so people only need to press the keys.
  • One button instead of two. The popup had Done and Close buttons that did the same thing, as well as the × button. It now shows only Done and the ×. The question popup has a new hideCancel option for this. The hidden button is also disabled, so pressing Tab skips it. The other questions that use the popup still show both buttons.
  • Credits. The contributor who wrote Handle clipboard failures with manual copying #51 is added to the contributors list in the README.
  • Docs. docs/compliance.md describes the new copy step.

Testing

  • All 25 unit tests pass (node --test tests/). The new tests cover these cases:
    • The clipboard feature is missing, exists without a usable copy function, refuses, or throws an error. In each case, the older copy command copies the selected text and the hidden text box is removed.
    • Both methods fail, so the popup opens with the original text and only one button.
    • Focus goes back to the control that started the copy, but not if that control was removed before the copy finished.
  • In headless Chromium, I clicked a copy button with the clipboard feature set to refuse:
    • The older copy command copied the full text. No popup opened, no hidden text box was left behind, and focus went back to the button.
    • When I also made the older command fail, the popup opened with the new message and only the Done button. The text was focused and fully selected.
    • The page reported no errors.

When the browser refuses to copy, the popup now says so directly and
tells people to press Ctrl+C (Cmd+C on a Mac), since the text is
already selected. The popup now shows one Done button instead of Done
and Close buttons that did the same thing. The question popup has a new
hideCancel option for this, and the hidden button is also disabled so
keyboard focus skips it.

Also add @NehonaYa to the contributors list in the README.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-27T21:09:08.106295Z 5a7a822 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Some pages block the browser's clipboard feature or don't offer it at
all, such as pages opened over plain http. The browser's older copy
command often still works there. Copy buttons now try that command,
using a hidden text box that is removed right away, before they show
the popup for copying by hand. Keyboard focus then goes back to the
control that started the copy if it is still on the page.

The question popup also checks that the control it returns focus to is
still on the page.

New tests cover a clipboard feature that exists but can't be used, the
older copy command working and failing, and a control that is removed
before the copy finishes. docs/compliance.md describes the new step.
@gabrielmongefranco Gabriel Mongefranco (gabrielmongefranco) changed the title Clarify the manual copy popup and credit a contributor Improve copying when the clipboard is blocked, and credit a contributor Oct 27, 2026
@gabrielmongefranco
Gabriel Mongefranco (gabrielmongefranco) merged commit 2b23098 into main Oct 27, 2026
1 check passed
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.

1 participant