chore(a11y): cleanup

This commit is contained in:
moklick
2025-06-03 14:04:48 +02:00
parent 1a3e293bf9
commit 65e912a755
2 changed files with 7 additions and 9 deletions
@@ -36,18 +36,15 @@ function AriaLiveMessage({ rfId }: { rfId: string }) {
export function A11yDescriptions({ rfId, disableKeyboardA11y }: { rfId: string; disableKeyboardA11y: boolean }) { export function A11yDescriptions({ rfId, disableKeyboardA11y }: { rfId: string; disableKeyboardA11y: boolean }) {
const labelConfig = useStore(labelConfigSelector); const labelConfig = useStore(labelConfigSelector);
const nodeDesc = disableKeyboardA11y
? labelConfig['a11yDescription.node.default']
: labelConfig['a11yDescription.node.keyboardDisabled'];
const edgeDesc = labelConfig['a11yDescription.edge.default'];
return ( return (
<> <>
<div id={`${ARIA_NODE_DESC_KEY}-${rfId}`} style={style}> <div id={`${ARIA_NODE_DESC_KEY}-${rfId}`} style={style}>
{nodeDesc} {disableKeyboardA11y
? labelConfig['a11yDescription.node.default']
: labelConfig['a11yDescription.node.keyboardDisabled']}
</div> </div>
<div id={`${ARIA_EDGE_DESC_KEY}-${rfId}`} style={style}> <div id={`${ARIA_EDGE_DESC_KEY}-${rfId}`} style={style}>
{edgeDesc} {labelConfig['a11yDescription.edge.default']}
</div> </div>
{!disableKeyboardA11y && <AriaLiveMessage rfId={rfId} />} {!disableKeyboardA11y && <AriaLiveMessage rfId={rfId} />}
</> </>
@@ -40,7 +40,7 @@ export function NodeWrapper<NodeType extends Node>({
nodeClickDistance, nodeClickDistance,
onError, onError,
}: NodeWrapperProps<NodeType>) { }: NodeWrapperProps<NodeType>) {
const { node, internals, isParent, labelConfig } = useStore((s) => { const { node, internals, isParent } = useStore((s) => {
const node = s.nodeLookup.get(id)! as InternalNode<NodeType>; const node = s.nodeLookup.get(id)! as InternalNode<NodeType>;
const isParent = s.parentLookup.has(id); const isParent = s.parentLookup.has(id);
@@ -48,7 +48,6 @@ export function NodeWrapper<NodeType extends Node>({
node, node,
internals: node.internals, internals: node.internals,
isParent, isParent,
labelConfig: s.labelConfig,
}; };
}, shallow); }, shallow);
@@ -143,6 +142,8 @@ export function NodeWrapper<NodeType extends Node>({
// prevent default scrolling behavior on arrow key press when node is moved // prevent default scrolling behavior on arrow key press when node is moved
event.preventDefault(); event.preventDefault();
const { labelConfig } = store.getState();
store.setState({ store.setState({
ariaLiveMessage: labelConfig['a11yDescription.ariaLiveMessage']({ ariaLiveMessage: labelConfig['a11yDescription.ariaLiveMessage']({
direction: event.key.replace('Arrow', '').toLowerCase(), direction: event.key.replace('Arrow', '').toLowerCase(),