Skip to content

Labels: print button and accessible print dialog - #4

Open
mgilardi wants to merge 8 commits into
co/labels-sheetsfrom
co/labels-print-dialog
Open

mgilardi wants to merge 8 commits into
co/labels-sheetsfrom
co/labels-print-dialog

Conversation

@mgilardi

Copy link
Copy Markdown
Contributor

Captive Origins task K6, following the plugin design (Printing section).

Stacks on #3 (co/labels-sheets).

  • Option collections adds a Print labels button to list and edit views
  • Modal dialog: template, media, keyboard start-slot grid, copies; shows endpoint errors in plain words
  • WCAG 2.2 AA aims: focus in, trapped and returned, Escape, labels, visible focus

Tested: 62 tests (jsdom, fetch mocked), tsc, leak check. Not tested: real Payload admin, screen reader.

🤖 Generated with Claude Code

mgilardi and others added 4 commits November 16, 2026 07:21
An admin field component for a template's elements. A layers list with keyboard selection and announced reorder, hide and delete; an inspector for the selected layer; and an SVG preview from the same layout as printing, with a sample record and a warnings list. Styled with Payload theme variables.

Not tested: a real browser, a screen reader, the Payload admin, color contrast.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Printing needed a way in from the admin. A button on opted-in collections opens
a modal with template, media, a keyboard-operable start-slot grid and copies,
and calls the print endpoint, showing its refusals in plain words.

Tested in jsdom with fetch mocked. Not tested in a real Payload admin, a
browser or with a screen reader; the two Payload wrappers are only type-checked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main took the core branch by rebase, so the same changes sit under new
commit ids. Main's tree matches the core branch exactly, so this keeps the
branch tree. Nothing is rewritten. Tests: see pull request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mgilardi

Copy link
Copy Markdown
Contributor Author

Security and privacy review (EXTANT APE, Head of Research for Simon)

Verdict: changes. CI is red, and the dialog loses focus while it prints.

Fix before merge

  1. CI fails at npm ci: package-lock.json doesn't match package.json (missing @payloadcms/ui, next, react, react-dom). Run npm install and commit the lockfile. Local: 62 of 62 tests pass after a fresh install.
  2. Focus is lost while printing. The Print button is set disabled while busy, so a keyboard user's focus drops to body. The Tab trap and Escape are handled on the dialog box, so both stop working. That contradicts "Tab stays inside" and "Escape returns focus". Clicking the backdrop also takes focus out. Use aria-disabled (or move focus to the status line), and make the background inert. A test should press Print from the keyboard and check that focus stays in the dialog.
  3. Rebase onto Add the template editor: layers, inspector and live preview #2 once it merges. Both add src/client/index.ts, the ./client export and the tsconfig JSX change. Labels: print button and accessible print dialog #4 marks the react and @payloadcms/ui peers optional, which is wrong once Add the template editor: layers, inspector and live preview #2's editor field is always registered.

Worth checking
4. The role="status" result and the start-slot status are added to the page with their text already in them, and screen readers often skip live regions added that way. Render the regions empty, then fill them. The CHANGELOG says screen readers weren't tested.
5. The Tab-trap selector button:not([disabled]) also matches slot buttons with tabIndex=-1. It works today only because the first and last controls happen to be a select and a button. Exclude [tabindex="-1"].
6. Unknown: with Payload's select-all across pages, selectedIDs may hold only the current page, so a print would be silently partial. Worth a test or a check against Payload 3.93.

Checked and fine: access is enforced on the server. The template and media lists are fetched as the person, and there are no client-only checks. The new dev dependencies are all MIT.

🤖 Generated with Claude Code

mgilardi and others added 4 commits November 16, 2026 09:48
The review found a stored XSS: thickness and rotation reached the live
preview unescaped, and the elements field had no checks. Elements are now
validated on the server and every SVG number is coerced to a finite number.

Tested: 4 new tests (58 pass). Not tested: the editor in a browser.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	CHANGELOG.md
#	test/sheets.test.ts
# Conflicts:
#	CHANGELOG.md
#	README.md
#	docs/decisions.md
#	docs/test-audit.md
#	package.json
#	src/client/index.ts
#	tsconfig.json
Review fixes. The Print button used disabled, which dropped focus to the page;
it now uses aria-disabled, focus is pulled back if it leaves, the Tab trap
skips tabindex -1 controls, and live regions are rendered empty then filled.
Merged sheets and the inspector branch, settling the shared client files
(react and @payloadcms/ui are required peers) and regenerated the lockfile so
npm ci passes.

Tested: 2 new jsdom tests (79 pass). Not tested: a real screen reader and
select-all across pages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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