Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/components/DraggableList/SortableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,33 @@ function SortableItem({id, children, disabled = false, isFocused = false}: Sorta
}
};

// Screen readers (e.g. JAWS in Virtual PC Cursor mode) activate elements via the
// accessibility API rather than dispatching a keydown event. This produces a click
// on the focused wrapper div instead of the inner pressable. Forward that click to
// the inner pressable so Enter works correctly with assistive technology.
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
if (isDragging || e.target !== node.current) {
return;
}
const innerPressable = node.current?.querySelector<HTMLElement>(PRESSABLE_SELECTOR);
if (innerPressable) {
innerPressable.click();
}
};

return (
<div
ref={setNodeRef}
style={style}
// Use capture phase to intercept Enter before inner MenuItem handles it
onKeyDownCapture={handleKeyDown}
onClick={handleClick}
// eslint-disable-next-line react/jsx-props-no-spreading
{...attributes}
// eslint-disable-next-line react/jsx-props-no-spreading
{...(disabled ? {} : listeners)}
role="button"
tabIndex={0}
>
{children}
</div>
Expand Down
Loading