Balancing auto-dismiss timeouts with screen reader announcement in Foundation Alerts
0 reputation · 03 Aug 2024, 03:25 UTC
0 reputation · 03 Aug 2024, 03:25 UTC
Configuring Zurb Foundation Alert boxes for useful, non-intrusive notifications raises a trade-off between persistence and noise. The Alert plugin activates elements with data-alert, adds a dismiss control with data-close, and supports automatic dismissal via data-options timeout. Programmatic open and close are also available through the JavaScript API.
A design constraint is that the default markup does not include ARIA live region attributes, so announcement behavior for assistive technology is not guaranteed without manual additions. Automatic timeouts reduce visual noise but may remove content before it is read, and multiple alerts stack in document flow which can cause layout shifts unless positioning is overridden.
Does the Alert plugin require manual role="alert" or aria-live attributes to ensure screen reader announcement? Which timeout value or dismissal strategy keeps alerts useful without creating notification noise when several alerts appear together? Can programmatic open and close coexist with a data-options timeout without conflicting behavior?
role="alert" or aria-live by default. Without them, screen readers may not announce the alert at all.data-options timeout if you manage the sequence: call $(el).foundation('open') after the element exists, and ensure any manual close() clears the internal timer to avoid double-dismissal races.The Alert plugin treats data-alert as a simple dismissible container. It adds a close button via data-close and reads data-options='{"timeout": 3000}' for auto-dismiss, but it does not inject ARIA live-region attributes. Assistive technology therefore sees only a generic <div> that disappears—no announcement, no persistent region.
<div class="alert callout" data-alert data-options="timeout: 4000" role="alert" aria-live="polite">
<p>Your message here</p>
<button class="close-button" data-close aria-label="Dismiss alert">
<span aria-hidden="true">×</span>
</button>
</div>id and append to a positioned container (position: fixed; top: 1rem; right: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 9999).instance._timer && clearTimeout(instance._timer) before a manual close() to prevent the auto-dismiss callback from firing on an already-removed element.role="alert" and aria-live="polite" are present.data-options='{"timeout": 500}', trigger with a screen reader (NVDA, VoiceOver), and verify the message is cut off. Repeat with 4000 and confirm full announcement.Which Foundation version are you targeting (6.x vs. the legacy 5.x)? The internal timer property name (_timer vs. timer) and event hooks differ slightly, so the exact programmatic cleanup snippet depends on that version.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.