Merge "Ensure page load popupNotification is closed when the toggle button is clicked"

This commit is contained in:
jenkins-bot 2023-05-03 21:49:39 +00:00 committed by Gerrit Code Review
commit 569c52799c

View file

@ -133,14 +133,18 @@ function addLimitedWidthPopup( container, message, onDismiss = () => {} ) {
`;
const popupFrag = document.createRange().createContextualFragment( popupTemplateString );
container.appendChild( popupFrag );
const closeButton = /** @type {HTMLElement} */ ( document.querySelector( '.vector-limited-width-popup-close-button' ) );
closeButton.addEventListener( 'click', () => {
const closePopup = () => {
const popup = /** @type {HTMLElement} */ ( document.querySelector( '.vector-limited-width-popup' ) );
if ( popup && popup.parentElement ) {
popup.parentElement.removeChild( popup );
}
onDismiss();
}, { once: true } );
};
const closeButton = /** @type {HTMLElement} */ ( document.querySelector( '.vector-limited-width-popup-close-button' ) );
closeButton.addEventListener( 'click', closePopup, { once: true } );
const toggle = /** @type {HTMLElement} */ ( document.querySelector( '.vector-limited-width-toggle' ) );
toggle.addEventListener( 'click', closePopup, { once: true } );
}
module.exports = init;