Skip to content

Copy inside modal dialogs and fullscreen elements - #2

Merged
silverwind merged 3 commits into
masterfrom
modal-copy
Oct 18, 2026
Merged

silverwind merged 3 commits into
masterfrom
modal-copy

Conversation

@silverwind

Copy link
Copy Markdown
Owner

While a modal <dialog> or a fullscreen element is open, everything outside of it is inert. The execCommand fallback appended its textarea to document.body, so it could not hold the selection and the copy silently copied nothing while still returning true (false in WebKit).

The textarea is now appended inside the focused element's :modal element, falling back to the first :modal element when focus is lost. Both lookups are needed because the top layer order is not exposed (whatwg/html#9075).

Written by Claude.

silverwind and others added 3 commits October 18, 2026 14:50
While a modal dialog or a fullscreen element is open, everything outside
of it is inert, so the execCommand fallback's textarea appended to the
body could not hold the selection and the copy silently copied nothing
while still reporting success. Append it inside the focused element's
modal element instead, falling back to the first one when focus is lost.

Co-Authored-By: Claude (Opus 5.5) <noreply@anthropic.com>
Explains why the lookup needs two steps: the topmost modal element is
not exposed by any API.

Co-Authored-By: Claude (Opus 5.5) <noreply@anthropic.com>
The same-line comment made the line hard to read.

Co-Authored-By: Claude (Opus 5.5) <noreply@anthropic.com>
@silverwind
silverwind merged commit b0392fa into master Oct 18, 2026
8 checks passed
@silverwind
silverwind deleted the modal-copy branch October 18, 2026 12:59
silverwind added a commit that referenced this pull request Oct 18, 2026
* Copy inside modal dialogs and fullscreen elements (#2) (silverwind)
* Disable pnpm's dlx cache (silverwind)
* update deps (silverwind)
* Consolidate tests (silverwind)
* Fix stray colon in README options (silverwind)
* Run all make targets in CI (silverwind)
* Remove duplicate release job permissions (silverwind)
* Align Makefile targets (silverwind)
* Simplify tests and demo page (silverwind)
* Fix stale README claims (silverwind)
* Align Makefile targets (silverwind)
* Update dependencies (silverwind)
* Unify README usage section (silverwind)
* Cancel superseded CI runs (silverwind)
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