Skip to content

Commit

Permalink
Revert "Removed keyboard event limitation for the live area"
Browse files Browse the repository at this point in the history
This reverts commit fc9bc7a
  • Loading branch information
oleksandr-danylchenko committed Aug 22, 2024
1 parent 7b61c22 commit f09e612
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const useAnnouncePopupOpening = (args: { message?: string, floatingOpen:

announce('', 'polite');
return () => destroyAnnouncer();
}, []);
}, [message]);

/**
* Screen reader requires messages to always be unique!
Expand All @@ -47,7 +47,7 @@ export const useAnnouncePopupOpening = (args: { message?: string, floatingOpen:
const idleTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);

useEffect(() => {
if (!floatingOpen || !message) return;
if (!floatingOpen || event?.type !== 'keydown' || !message) return;

const scheduleIdleAnnouncement = () => {
clearTimeout(idleTimeoutRef.current);
Expand All @@ -61,5 +61,5 @@ export const useAnnouncePopupOpening = (args: { message?: string, floatingOpen:
clearTimeout(idleTimeoutRef.current);
store.unobserve(scheduleIdleAnnouncement);
};
}, [floatingOpen, event?.type, announcePopupNavigation, store]);
}, [floatingOpen, event?.type, message, announcePopupNavigation, store]);
};

0 comments on commit f09e612

Please sign in to comment.