Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: #39862 #39927

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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