Don't hide then reveal alerts
dont-hide-then-reveal-alerts
Don’t hide-then-reveal alerts in the DOM — older AT can still perceive visually hidden messages that are not currently applicable.
Description
USWDS warns against hide-then-reveal alerts in the DOM because older assistive technology can still perceive visually hidden messages that are not currently applicable. Inapplicable alerts should not remain visually hidden waiting to be “revealed.” Keep only applicable alerts in the DOM; remove or omit the others rather than toggling visibility alone so AT users are not flooded with stale warnings.
When to use
Managing alert presence for screen-reader-safe show and hide behavior.
Not when
Alerts that are currently applicable and meant to be perceived.
Agent hint
Remove inapplicable alerts from the DOM; do not park them visually hidden for later.
Inapplicable alerts are not left visually hidden in the DOM.
Alerts stay in the DOM as visually hidden until “revealed.”
Citations
USWDS — Alert
https://designsystem.digital.gov/components/alert/