A very lightweight and flexible accessible modal dialog script.
MIT License
Bot releases are hidden (Show)
Published by KittyGiraudel over 3 years ago
Published by KittyGiraudel over 3 years ago
this._listeners
being undefined in .off
method (#148)Published by KittyGiraudel over 3 years ago
In theory, v6.0.0 should be entirely backward compatible with the latest version from v5. However since the move to Rollup could have unintended side-effect, we’re leaning on the safe side and bumping the major. If you are experiencing any issue with v6, please kindly report them.
Package
Documentation
<dialog>
in the documentation (#137)Tests
Published by KittyGiraudel over 3 years ago
Published by KittyGiraudel over 3 years ago
Published by KittyGiraudel over 3 years ago
Published by KittyGiraudel over 3 years ago
master
to main
(9718f2a479620a74d4e42930fcd3ab25eaee445b)Published by KittyGiraudel almost 4 years ago
Published by KittyGiraudel about 4 years ago
aria-hidden
(#119, by @patrickhlauke)Published by KittyGiraudel about 4 years ago
aria-hidden
for dialog siblings (#117, by @patrickhlauke)Published by KittyGiraudel over 4 years ago
Published by KittyGiraudel over 4 years ago
Published by KittyGiraudel over 4 years ago
Published by KittyGiraudel about 6 years ago
role="alertdialog"
(#98, by @flu0)Published by KittyGiraudel over 6 years ago
Published by KittyGiraudel over 6 years ago
Published by KittyGiraudel over 6 years ago
<dialog>
element — Thanks to @leimi for the feature request and original implementation (#91, #92)Published by KittyGiraudel over 6 years ago
Published by KittyGiraudel over 6 years ago
role="dialog"
is always set —even when <dialog>
is natively supported— for better screen-reader supportPublished by KittyGiraudel over 6 years ago
The version 5.0.0 of a11y-dialog aims at leveraging the native <dialog>
element from HTML 5.2 when available. On user-agents which do not support <dialog>
, it will keep working as previously (a few variations to be found below).
This version involves quite a few breaking changes and expects a different initial DOM and styling base than version 4. Find below a list of changes and a migration guide.
Pull-request: https://github.com/edenspiekermann/a11y-dialog/pull/77.
data-a11y-dialog-native
attribute (with no value) to the dialog container when the <dialog>
element and all its functionalities are natively supported. The following check is performed to see if it is natively supported: (439e1cc0bf0b43fb283b0e29a32f9e0301ece827)'show' in document.createElement('dialog')
aria-hidden="true"
(implied by the <dialog>
element or handled by the script). (0a8052abd0af769a538bda968527641738b8fc59)- <div id="my-accessible-dialog" aria-hidden="true">
+ <div id="my-accessible-dialog">
<dialog>
element and therefore no longer expects a role="dialog"
(implied by the <dialog>
element or ensured by the script). (de239a421fd8ebc8b67a236f7152ad89a249e9d5)- <div role="dialog" aria-labelledby="dialog-title">
+ <dialog aria-labelledby="dialog-title">
role="document"
(implied by the <dialog>
element or optional otherwise). (00da776cce38ab4fcf2425541fdee31c7c17f090)- <div role="document">
object
and embed
elements are no longer considered focusable.tabindex
is no longer considered focusable.inert
attribute is no longer considered focusable.+ [data-a11y-dialog-native] > :first-child {
+ display: none;
+ }
+ dialog[open] {
+ display: block;
+ }
.dialog-container[aria-hidden='true'] {
display: none;
}
shown
property now properly reflects the status of the DOM instead of ensuring the dialog is closed. It means a dialog can theoretically be started open with the open
attribute however I highly recommend not to do that. (1112ff54557fdfc91ce8c5492b3bb2db5505b465)<!-- Highly discouraged yet possible -->
<dialog open>
node
property previously holding the dialog container has been renamed container
. (eb2c1e4b7973828befb9e986351e4acda80fd813)const container = document.querySelector('#my-accessible-dialog');
const instance = new A11yDialog(container);
// instance.container === container
dialog
property. (8348a798b33787479bd3b37e60a45a8976d6f722)const container = document.querySelector('#my-accessible-dialog');
const instance = new A11yDialog(container);
// instance.dialog === container.querySelector('dialog')
[BREAKING] The app container(s) (likely the dialog container’s siblings) no longer have their aria-hidden
attribute toggled on open/close when <dialog>
is natively supported (implied by the native behaviour). Additionally, the script no longer preservers and restores the original aria-hidden
attribute from the dialog container and its siblings. (bd394600c572a1b01174d54de9ca39e61c4f7ec2)
The script now toggles an open
attribute on the dialog element on open/close to be in sync with the native behaviour.
const container = document.querySelector('#my-accessible-dialog');
const instance = new A11yDialog(container);
instance.show()
// instance.dialog.hasAttribute('open') === true
showModal()
and close()
methods when supported, following their signature. (be55273e25fb2c000245a58598338f7206605c5a)const container = document.querySelector('#my-accessible-dialog');
const instance = new A11yDialog(container);
instance.hide('something');
// instance.dialog.returnValue === 'something'
autofocus
attribute will be focused to respect the dialog focusing steps from the specifications. If none present, the first focusable element will be focused as before. (23e52f8ce88cb16b75fa352db7a27b7f7ecd6ab1)