Skip to content

Commit

Permalink
feat: added support for aria-hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandrshy committed Jul 8, 2020
1 parent dcca80b commit ff9cdfc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<button class="modal__button" data-keukenhof-open="#modal">
Open modal
</button>
<div id="modal" class="modal" role="dialog">
<div id="modal" class="modal" role="dialog" aria-hidden="true">
<div class="modal__overlay" data-keukenhof-close>
</div>
<div class="modal__container">
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const Keukenhof = ((): KeukenhofType => {
const isContinue = this.beforeOpen(event);
if (!isContinue) return;
this.$modal?.classList.add(this.openClass);
this.setAraiHidden(false);
this.changeScrollBehavior(SCROLL_STATE.DISABLE);
this.addEventListeners();
this.preparationOpeningModal(event);
Expand Down Expand Up @@ -117,6 +118,7 @@ export const Keukenhof = ((): KeukenhofType => {
close(event?: Event) {
const isContinue = this.beforeClose(event);
if (!isContinue) return;
this.setAraiHidden(true);
this.changeScrollBehavior(SCROLL_STATE.ENABLE);
this.removeEventListeners();
this.preparationClosingModal(event);
Expand Down Expand Up @@ -204,6 +206,15 @@ export const Keukenhof = ((): KeukenhofType => {
element.style.overflow = this.scrollBehavior.defaultValue;
else if (value === SCROLL_STATE.DISABLE) element.style.overflow = 'hidden';
}

/**
* Set value for arai-hidden
*
* @param {boolean} value - aria-hidden value
*/
setAraiHidden(value: boolean) {
this.$modal?.setAttribute('aria-hidden', String(value));
}
}

let modal: ModalType;
Expand Down

0 comments on commit ff9cdfc

Please sign in to comment.