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

View File

@@ -36,18 +36,15 @@ function AriaLiveMessage({ rfId }: { rfId: string }) {
export function A11yDescriptions({ rfId, disableKeyboardA11y }: { rfId: string; disableKeyboardA11y: boolean }) {
const labelConfig = useStore(labelConfigSelector);
const nodeDesc = disableKeyboardA11y
? labelConfig['a11yDescription.node.default']
: labelConfig['a11yDescription.node.keyboardDisabled'];
const edgeDesc = labelConfig['a11yDescription.edge.default'];
return (
<>
<div id={`${ARIA_NODE_DESC_KEY}-${rfId}`} style={style}>
{nodeDesc}
{disableKeyboardA11y
? labelConfig['a11yDescription.node.default']
: labelConfig['a11yDescription.node.keyboardDisabled']}
</div>
<div id={`${ARIA_EDGE_DESC_KEY}-${rfId}`} style={style}>
{edgeDesc}
{labelConfig['a11yDescription.edge.default']}
</div>
{!disableKeyboardA11y && <AriaLiveMessage rfId={rfId} />}
</>

View File

@@ -40,7 +40,7 @@ export function NodeWrapper<NodeType extends Node>({
nodeClickDistance,
onError,
}: 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 isParent = s.parentLookup.has(id);
@@ -48,7 +48,6 @@ export function NodeWrapper<NodeType extends Node>({
node,
internals: node.internals,
isParent,
labelConfig: s.labelConfig,
};
}, shallow);
@@ -143,6 +142,8 @@ export function NodeWrapper<NodeType extends Node>({
// prevent default scrolling behavior on arrow key press when node is moved
event.preventDefault();
const { labelConfig } = store.getState();
store.setState({
ariaLiveMessage: labelConfig['a11yDescription.ariaLiveMessage']({
direction: event.key.replace('Arrow', '').toLowerCase(),