Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
EuiPageHeader,
EuiPagination,
EuiPopover,
EuiScreenReaderLive,
EuiSpacer,
EuiText,
} from '@elastic/eui';
Expand Down Expand Up @@ -162,6 +163,7 @@ export const SharedLists = React.memo(() => {

const [exportDownload, setExportDownload] = useState<{ name?: string; blob?: Blob }>({});
const [displayImportListFlyout, setDisplayImportListFlyout] = useState(false);
const [screenReaderMessage, setScreenReaderMessage] = useState('');
const { addError, addSuccess } = useAppToasts();

// Loading states
Expand Down Expand Up @@ -216,7 +218,18 @@ export const SharedLists = React.memo(() => {
const handleExportSuccess = useCallback(
(listId: string, name: string) =>
(blob: Blob): void => {
addSuccess(i18n.EXCEPTION_LIST_EXPORTED_SUCCESSFULLY(name));
const message = i18n.EXCEPTION_LIST_EXPORTED_SUCCESSFULLY(name);
addSuccess(message);
// If the same list is exported twice in a row, React won't re-render
// since state hasn't changed, so the live region won't re-announce.
// Clearing to '' first ensures VoiceOver sees a new change on the next frame.
setScreenReaderMessage((current) => {
if (current === message) {
requestAnimationFrame(() => setScreenReaderMessage(message));
return '';
}
return message;
});
setExportDownload({ name: listId, blob });
},
[addSuccess]
Expand Down Expand Up @@ -480,6 +493,9 @@ export const SharedLists = React.memo(() => {

return (
<>
<EuiScreenReaderLive aria-live="assertive" aria-atomic="true" focusRegionOnTextChange>
{screenReaderMessage}
</EuiScreenReaderLive>
<MissingDetectionsPrivilegesCallOut />
<EuiPageHeader
pageTitle={i18n.ALL_EXCEPTIONS}
Expand Down
Loading