Conversation
Screen readers announced the toggle list / toggle heading button as a bare "button": it had no accessible name, its chevron SVG was not hidden, and nothing exposed whether the nested blocks were shown. The button now gets a localized aria-label, the SVG is aria-hidden, and aria-expanded follows data-show-children in both the vanilla and React toggle wrappers. The vanilla node view ignores the aria-expanded mutation the same way it already ignores data-show-children, so toggling does not re-render the block. The HTML exporter, which forces toggles open, sets aria-expanded="true" to match. Fixes TypeCellOS#2811
|
@adarshsm is attempting to deploy a commit to the TypeCell Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
@blocknote/xl-typst-exporter
commit: |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #2811. Screen readers can't identify the collapse/expand button on toggle list items and toggle headings. It has no accessible name, its chevron SVG isn't hidden from assistive technology, and nothing tells the user whether the nested blocks are shown.
Rationale
createToggleWrapper(vanilla) andToggleWrapper(React) both render.bn-toggle-buttonas a plain<button type="button">containing only an SVG. The issue asks for an accessible name and a hidden decorative image. I used the standard disclosure pattern: one constant label, plusaria-expandedfor the state. With that, a screen reader announces "Expand or collapse, collapsed, button" and the name stays the same when the state changes.Changes
toggle_blocks.toggle_button_label("Expand or collapse"), added to all 23 core locales next to the existingtoggle_blocks.add_block_button.createToggleWrapper.ts):aria-labeland the SVG getsaria-hidden="true".data-show-childrennow go through a smallsetShowChildren()that also setsaria-expandedon the button, so the two attributes can't get out of sync.ignoreMutationnow also ignores thearia-expandedattribute change on the button, the same way it already ignoresdata-show-children. Without this, every toggle click re-rendered the node view (see Testing).ToggleWrapper.tsx):aria-label,aria-expanded={showChildren}, andaria-hiddenon the SVG.internalHTMLSerializer.ts):forceToggleBlocksShowalready forces exported toggles todata-show-children="true". It now also sets the button'saria-expanded="true", so exported HTML doesn't announce an open toggle as collapsed.Impact
blocknoteHTMLexport snapshots. Behaviour and styling are unchanged.Testing
packages/core/src/blocks/ToggleWrapper/createToggleWrapper.test.ts(jsdom). It mounts an editor with a toggle list item and checks the label, the hidden SVG, and thataria-expandedgoesfalse → true → falseacross two clicks. It also checks that the button element is still the same one after a click, i.e. the block was not re-rendered.expected null to be 'Expand or collapse'.ignoreMutationclause removed, the same-element check fails, which shows the clause is needed.blocknoteHTMLexport snapshots were updated. Before I added the exporter change, they showed a real inconsistency:data-show-children="true"next toaria-expanded="false".vp test --runinpackages/core,packages/react, andtests/src/unit: everything passes.vp lint --type-awareandvp fmt --checkare clean on the changed files.localStorageis shadowed by Node's built-in Web Storage, so the toggle-related tests needNODE_OPTIONS=--no-experimental-webstoragelocally. This affects the existing export tests too and doesn't come from this change.Checklist
🤖 Generated with Claude Code