aria-disabled buttonThis example uses aria-disabled instead of the native disabled attribute to temporarily prevent the "Save" button from being activated during processing.
Why aria-disabled instead of disabled? The native disabled attribute removes a button from the tab order, and if the button has keyboard focus at the moment it becomes disabled, focus is forced away, typically to the document body, leaving a keyboard user without a clear sense of where they are until focus is later redirected elsewhere. aria-disabled="true" keeps the button focusable and in place throughout, so a keyboard or screen reader user never loses their position. The trade-off: aria-disabled does not stop the button from being activated. Unlike disabled, which blocks form submission automatically, aria-disabled requires the developer to manually check its state and block the action in JavaScript, which this example does.
When the “Save” button is activated:
aria-disabled="true", and styled to look unavailable, but remains focusable.aria-disabled="true" will have no effect, this is checked and blocked in JavaScript.After 5 seconds:
aria-disabled attribute will be set back to "false".