feat(a11y): add aria live message on move by keyboard

This commit is contained in:
moklick
2022-08-16 18:21:20 +02:00
parent ee5352df8f
commit d2d4b76e65
8 changed files with 43 additions and 17 deletions
@@ -1,16 +1,14 @@
import { useCallback } from 'react';
import { useStore, useStoreApi } from '../hooks/useStore';
import { UpdateNodeInternals, ReactFlowState } from '../types';
const selector = (state: ReactFlowState) => state.updateNodeDimensions;
import { useStoreApi } from '../hooks/useStore';
import { UpdateNodeInternals } from '../types';
function useUpdateNodeInternals(): UpdateNodeInternals {
const store = useStoreApi();
const updateNodeDimensions = useStore(selector);
return useCallback<UpdateNodeInternals>((id: string) => {
const nodeElement = store.getState().domNode?.querySelector(`.react-flow__node[data-id="${id}"]`) as HTMLDivElement;
const { domNode, updateNodeDimensions } = store.getState();
const nodeElement = domNode?.querySelector(`.react-flow__node[data-id="${id}"]`) as HTMLDivElement;
if (nodeElement) {
requestAnimationFrame(() => updateNodeDimensions([{ id, nodeElement, forceUpdate: true }]));