Affected version
@blocknote/react@0.52.1 and current main at dee7880b89b1e9bc00b4f4481f32652c7a4b4408.
Problem
Both SuggestionMenuWrapper and GridSuggestionMenuWrapper conditionally set
aria-activedescendant using the truthiness of selectedIndex. The initial
selected index is numeric 0, so the editor contenteditable omits the
attribute even though the first suggestion is selected.
Affected sources:
packages/react/src/components/SuggestionMenu/SuggestionMenuWrapper.tsx
packages/react/src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenuWrapper.tsx
Reproduction
- Mount
BlockNoteViewRaw with the public SuggestionMenuController.
- Open a standard slash suggestion menu with at least one item.
- Inspect the editor contenteditable while the first item is selected.
- Repeat with the grid suggestion-menu wrapper.
The first item is visibly selected, but aria-activedescendant is absent.
Moving to index 1 makes the attribute appear.
Expected
aria-activedescendant="bn-suggestion-menu-item-0"
No selection should continue to omit the attribute.
Cause and minimal fix
The wrappers currently use a truthy check:
"aria-activedescendant": selectedIndex
? "bn-suggestion-menu-item-" + selectedIndex
: undefined,
Use an explicit undefined check:
"aria-activedescendant":
selectedIndex !== undefined
? "bn-suggestion-menu-item-" + selectedIndex
: undefined,
Tests should cover first, middle, last, and no-selection states for both the
standard and grid wrappers.
This affects assistive technology because the active-option relation is
missing until keyboard navigation reaches a nonzero index.
Affected version
@blocknote/react@0.52.1and currentmainatdee7880b89b1e9bc00b4f4481f32652c7a4b4408.Problem
Both
SuggestionMenuWrapperandGridSuggestionMenuWrapperconditionally setaria-activedescendantusing the truthiness ofselectedIndex. The initialselected index is numeric
0, so the editor contenteditable omits theattribute even though the first suggestion is selected.
Affected sources:
packages/react/src/components/SuggestionMenu/SuggestionMenuWrapper.tsxpackages/react/src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenuWrapper.tsxReproduction
BlockNoteViewRawwith the publicSuggestionMenuController.The first item is visibly selected, but
aria-activedescendantis absent.Moving to index
1makes the attribute appear.Expected
No selection should continue to omit the attribute.
Cause and minimal fix
The wrappers currently use a truthy check:
Use an explicit undefined check:
Tests should cover first, middle, last, and no-selection states for both the
standard and grid wrappers.
This affects assistive technology because the active-option relation is
missing until keyboard navigation reaches a nonzero index.