Skip to content

fix(zoom)!: open nested items by keyboard, skip hidden ones, and load data-zoom-src behind the page image - #16

Merged
onmax merged 4 commits into
mainfrom
fix/zoom-review
Oct 20, 2026
Merged

onmax merged 4 commits into
mainfrom
fix/zoom-review

Conversation

@onmax

@onmax onmax commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Fixes from an audit of comark-zoom, plus the theming cleanup agreed for 0.2. Stacked on #13.

Breaking

  • The six --cz-* variables are gone (--cz-backdrop, --cz-ink, --cz-muted, --cz-line, --cz-hover, --cz-active). --cz-active even stood for two different tokens. To theme only the zoomed view, set the shared --comark-* tokens on .cz-dialog; a new e2e test checks that this themes the zoom and leaves the page alone.
  • The thumbnail strip is role="group"; it was a tablist with no tabs.
  • ::zoom passes id and class through in every renderer and drops other attributes. Before, Vue passed everything and the others nothing.
  • data-zoom=false, or {zoom=false} on an image, opts an element out. Before, it still zoomed on click.
  • Images zoom no further than their natural size.

Fixes

  • Keyboard opening: Enter on a screenshot inside a carousel slide opened slide 1, because keyboard opening skipped the nested-item rule that clicks follow. Nested items also stop being their own tab stop.
  • Hidden group items: items in a closed tab or a closed <details> are left out of a group. They used to open 1px wide at 4×. The docs page hit this itself.
  • data-zoom-src:
    • The copy shows the page's image until the large file has loaded, then swaps it, removing srcset and <picture> sources that would win over it. Before, it animated an empty box.
    • Thumbnails keep the page's image, so a gallery of large files no longer downloads all of them on open.
  • Late images: the copy is placed again when its images load, so a lazy image or a large file with another aspect ratio no longer overflows the stage.
  • Hand-marked items: an element marked {data-zoom} by hand gets the script and a tabindex, so zoom({ images: false }) plus one marked image works.
  • Event types: the events are typed on GlobalEventHandlersEventMap, so document.addEventListener("comark-zoom:open", …) type-checks as the docs show. A type test covers it.
  • Svelte: comark-zoom/svelte exports ZoomDetail.
  • start() without an argument: start() from comark-zoom/client now adds the bundled styles; before, calling it without the CSS gave unstyled output. The self-contained function the HTML renderer inlines moved to src/script.ts (AGENTS.md is updated).

New e2e tests cover each browser fix and fail against the old build. pnpm ready passes, and so do all 28 e2e tests on the full stack.

🤖 Generated with Claude Code

@pullfrog

pullfrog Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

This repo's model isn't fully set up yet.

OpenAI-compatible model selected but required configuration is missing: OPENAI_COMPATIBLE_API_KEY.

only the API key is sensitive — add it as a secret at https://github.com/onmax/comark-plugins/settings/secrets/actions. everything else is plain workflow env::

OPENAI_COMPATIBLE_BASE_URL: https://your-endpoint.example.com/v1
OPENAI_COMPATIBLE_API_KEY: ${{ secrets.OPENAI_COMPATIBLE_API_KEY }}
OPENAI_COMPATIBLE_MODEL:
OPENAI_COMPATIBLE_CONTEXT: "128000"
OPENAI_COMPATIBLE_MAX_OUTPUT: "16384"

set the last two to the real limits of the model your endpoint serves. Pullfrog can't
discover them — your endpoint owns the model catalog — and without them completions are
capped at 32000 tokens (rejected outright by models with a smaller cap) and
auto-compaction is disabled, so long runs grow until your endpoint refuses them.

for full setup instructions, see https://docs.pullfrog.com/openai-compatible

Configure model →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using gpt-5.6-sol | 𝕏

@onmax
onmax force-pushed the fix/carousel-review branch from fb88bb4 to 7bf4263 Compare October 20, 2026 08:30
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 062e66a 2026-10-20T11:08:48.882Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ f44e930 2026-10-20T09:49:38.614Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 115c643 2026-10-20T09:05:42.584Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ fdaff9c 2026-10-20T08:30:22.284Z Visit the dashboard ↗

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The latest commit introduces a regression for nested zoom items whose author explicitly sets tabindex="0": the new settlement pass removes that tab stop as if it were renderer-generated. Please preserve the author's explicit zero before merging.

Reviewed changes

The incremental review covers the changes since fdaff9c: hardening the line-height probe, guarding late image loads, restoring scroll settings during shutdown, and settling focusability for dynamically added nested zoom items.

  • Hardened the line-height probe — Isolated the measurement span from host CSS so page rules cannot change the zoom sizing decision.
  • Guarded asynchronous image work — Prevented stale image loads from mutating a closed or replaced zoom view.
  • Restored scroll state on shutdown — Added cleanup for history.scrollRestoration when the runtime is stopped while a dialog is open.
  • Observed late-added items — Replaced the one-time readiness hook with a mutation observer that settles nested tab stops as content arrives.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-5.6-sol | 𝕏

Comment thread packages/zoom/src/script.ts Outdated
// An item inside another one zooms with it, so only the outer one is a tab stop. Renderers can't know: a slide and
// the screenshot inside it come from different plugins. Any other tabindex is the author's and stays.
function settle() {
for (const node of document.querySelectorAll<HTMLElement>(`${SELECTOR}[tabindex="0"]`))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes an explicit author tabindex="0" from any nested [data-zoom] item, because the DOM contains no marker distinguishing that value from a renderer-added zero. As a result, an author who intentionally keeps a nested item in the tab order loses that behavior, despite the comment and test claiming author tabindex values are preserved.

Technical details
# Preserve explicit nested tabindex values

## Affected sites
- `packages/zoom/src/script.ts:101-102` — `settle()` removes every nested zoom item whose current attribute is `"0"`.
- `packages/zoom/src/index.ts:36` — `attrs.tabindex ??= "0"` collapses generated and author-provided zero values into the same output attribute.
- `packages/zoom/src/html.ts:27`, `packages/zoom/src/react.ts:29`, `packages/zoom/src/vue.ts:25`, `packages/zoom/src/svelte/Zoom.svelte:21` — renderers also emit generated `tabindex="0"` without provenance.

## Required outcome
- Nested items generated without an author tabindex should stop being tab stops.
- An author-provided `tabindex="0"` must remain intact, including for dynamically inserted markup.
- The implementation must retain enough provenance or use another explicit contract so these cases are distinguishable at settlement time.

## Suggested approach
- Mark generated tab stops separately, or otherwise preserve author tabindex provenance through parse/render and dynamic DOM insertion, then settle only generated nested values.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

This commit can still leave history.scrollRestoration stuck at "manual" when shutdown races with a page-initiated close.

Reviewed changes

This incremental review covers the changes since the prior Pullfrog review: shutdown now closes without traversing history, overlapping close/open handling keeps scroll locking active, and the nested-item settlement observer is retained for inserted nodes.

  • Separated shutdown from history navigation — stop() now closes the active view without invoking history.back() or relying on a late popstate listener.
  • Handled overlapping views — A zoom opened from a close event keeps scroll restoration manual until the replacement view closes.
  • Scoped mutation settlement — Newly added subtrees are settled rather than rescanning the whole document.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-5.6-sol | 𝕏

added.disconnect();
listeners.abort();
style?.remove();
void shut("stop");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stop() can race with a page-initiated close: shut("page") has already set current.closing and is waiting for the popstate/animation, then shutdown aborts the listener and calls shut("stop"), which returns immediately at line 468. That leaves the pending restoration value untouched and history.scrollRestoration stuck at "manual" after the runtime has stopped.

Technical details
# Restore scroll state when shutdown interrupts a close

## Affected sites
- `packages/zoom/src/script.ts:466-471` — the `current.closing` early return prevents the shutdown path from restoring a pending scroll setting.
- `packages/zoom/src/script.ts:588-594` — shutdown aborts the `popstate` listener before invoking `shut("stop")`, so the pending restoration callback cannot run.

## Required outcome
- Stopping the runtime during an in-flight page close must restore the page's original `history.scrollRestoration` setting and must not leave a late history traversal able to mutate the stopped runtime.

## Suggested approach
- Ensure shutdown resolves or cancels any pending restoration before or despite the closing guard, and define how the already-requested history traversal is handled after listeners are removed.

@onmax
onmax force-pushed the fix/carousel-review branch from 163951f to 212fe25 Compare October 20, 2026 11:04
@vite-hub
vite-hub Bot changed the base branch from fix/carousel-review to main October 20, 2026 11:06
@vite-hub

vite-hub Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

Pass interrupted; current webhook state retained.

Session

Pass interrupted; current webhook state retained.

Session

Pass interrupted; current webhook state retained.

Session

Pass interrupted; current webhook state retained.

Session

Pass interrupted; current webhook state retained.

Session

Pass interrupted; current webhook state retained.

Session

Pass interrupted; current webhook state retained.

onmax added 4 commits October 20, 2026 13:07
… data-zoom-src behind the page image

- Enter on an item inside another one (a screenshot in a carousel slide) opens the outer one, like a click.
  Nested items lose their tabindex when the script starts, so each slide is one tab stop.
- A group leaves out items with no size, such as those in a closed tab or a closed <details>.
- data-zoom-src: the copy keeps the page's image until the larger file has loaded, then drops srcset,
  sizes, and a picture's sources so the larger file wins.
- The strip's thumbnails keep the page's images and their loading attribute.
- The copy is placed again whenever one of its images loads, and is sized by its own height.
- An image without data-zoom-src zooms no larger than its natural size.
- An element marked `{data-zoom}` by hand zooms with `images: false` too, and gets tabindex="0".
- `{zoom=false}` on an image, or `data-zoom=false`, keeps it from zooming.
- `::zoom` keeps its id and class in every renderer and drops other attributes; Vue no longer passes
  them all through.
- The events are declared on GlobalEventHandlersEventMap, so document and window listeners type-check.
- The thumbnail strip is role="group" instead of a tablist.
- `start()` from comark-zoom/client adds the bundled styles when called with no argument. The
  self-contained function the HTML renderer inlines moved to src/script.ts.
- svelte/index.d.ts exports ZoomDetail, and the Svelte Zoom takes id and class.

BREAKING CHANGE: the --cz-backdrop, --cz-ink, --cz-muted, --cz-line, --cz-hover, and --cz-active
variables are gone. To theme only the zoomed view, set the --comark-* tokens on .cz-dialog.
BREAKING CHANGE: the thumbnail strip has role="group", not role="tablist".
BREAKING CHANGE: Vue's ::zoom no longer falls through attributes other than id and class.
…abindex, and port #11's probe and scroll fixes

- A MutationObserver, disconnected by stop(), takes the tab stop off items nested in another one as they appear, so
  apps that render after mount and client-side navigation get one stop per item. Only tabindex="0" goes; any other
  value is the author's.
- A large image that finishes loading after the view closed or moved on changes nothing.
- Port c69e187: the line-height probe uses important inline styles, and scroll restoration goes back however the zoom
  closes, including stop() while it's open.
…keeps scroll restoration off, and settle only added nodes

- Port 252e0d0: shut() takes where the close came from, and stop() never goes back in history, so a late popstate
  can't close a zoom opened after it. A zoom that opens before the last close has put scroll restoration back does
  it first.
- The observer looks only at added elements and their zoomable descendants, not the whole document on every
  mutation. The startup pass still covers the document.
- A comment says why a nested item's tabindex="0" goes even when the author set it.
@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/comark-annotate@16
pnpm add https://pkg.pr.new/comark-carousel@16
pnpm add https://pkg.pr.new/comark-zoom@16

commit: 062e66a

@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/comark-annotate@16
pnpm add https://pkg.pr.new/comark-carousel@16
pnpm add https://pkg.pr.new/comark-zoom@16

commit: 062e66a

@onmax
onmax merged commit bc560bf into main Oct 20, 2026
8 of 9 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 20, 2026
vite-hub Bot pushed a commit that referenced this pull request Oct 20, 2026
… too (#25)

#14 was squashed from a branch older than #16, so it added data-zoom-aside, copyOf, and originalOf to a copy of the
zoom script in client.ts, while the HTML renderer kept inlining script.ts without them. Pages rendered to HTML got
no aside and no mapping, and start() lost #16's fixes: keyboard opening of nested items, hidden items left out of a
group, and data-zoom-src loading behind the page image.

script.ts has the aside and the mapping again, on top of #16, and client.ts is the wrapper around it it was before.
An e2e test checks both on a page from the HTML renderer.
@onmax
onmax deleted the fix/zoom-review branch November 1, 2026 11:04
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