feat: add role prop to nodes

This commit is contained in:
Abbey Yacoe
2025-05-26 17:08:29 +02:00
parent 0af2f2801d
commit ba9df8eaf8
4 changed files with 21 additions and 4 deletions
@@ -39,6 +39,7 @@ export function NodeWrapper<NodeType extends Node>({
nodeTypes,
nodeClickDistance,
onError,
role,
}: NodeWrapperProps<NodeType>) {
const { node, internals, isParent } = useStore((s) => {
const node = s.nodeLookup.get(id)! as InternalNode<NodeType>;
@@ -154,7 +155,6 @@ export function NodeWrapper<NodeType extends Node>({
});
}
};
return (
<div
className={cc([
@@ -192,7 +192,7 @@ export function NodeWrapper<NodeType extends Node>({
onDoubleClick={onDoubleClickHandler}
onKeyDown={isFocusable ? onKeyDown : undefined}
tabIndex={isFocusable ? 0 : undefined}
role={isFocusable ? 'button' : undefined}
role={node.role === null ? undefined : node.role || (isFocusable ? 'button' : undefined)}
aria-describedby={disableKeyboardA11y ? undefined : `${ARIA_NODE_DESC_KEY}-${rfId}`}
aria-label={node.ariaLabel}
>