Skip to content

Commit

Permalink
Merge f1407d5 into d7b22b7
Browse files Browse the repository at this point in the history
  • Loading branch information
rickygarim committed Apr 27, 2024
2 parents d7b22b7 + f1407d5 commit dcef21a
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions js/src/modal.js
Expand Up @@ -169,38 +169,41 @@ class Modal extends BaseComponent {
}

_showElement(relatedTarget) {
// try to append dynamic modal
if (!document.body.contains(this._element)) {
document.body.append(this._element)
document.body.append(this._element);
}

this._element.style.display = 'block'
this._element.removeAttribute('aria-hidden')
this._element.setAttribute('aria-modal', true)
this._element.setAttribute('role', 'dialog')
this._element.scrollTop = 0
const scrollPosition = window.scrollY || document.documentElement.scrollTop;

const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog)
this._element.style.display = "block";
this._element.removeAttribute("aria-hidden");
this._element.setAttribute("aria-modal", "true");
this._element.setAttribute("role", "dialog");
this._element.scrollTop = 0;

const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
if (modalBody) {
modalBody.scrollTop = 0
modalBody.scrollTop = 0;
}

reflow(this._element)
reflow(this._element);

this._element.classList.add(CLASS_NAME_SHOW)
this._element.classList.add(CLASS_NAME_SHOW);

const transitionComplete = () => {
if (this._config.focus) {
this._focustrap.activate()
}
if (this._config.focus) {
this._focustrap.activate();
}

this._isTransitioning = false
window.scrollTo(0, scrollPosition);

const transitionComplete = () => {
this._isTransitioning = false;
EventHandler.trigger(this._element, EVENT_SHOWN, {
relatedTarget
})
}
relatedTarget,
});
};

this._queueCallback(transitionComplete, this._dialog, this._isAnimated())
this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
}

_addEventListeners() {
Expand Down

0 comments on commit dcef21a

Please sign in to comment.