Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -148,6 +149,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 @@ -202,7 +204,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 @@ -468,6 +481,9 @@ export const SharedLists = React.memo(() => {

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