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

Bug: T335153
Change-Id: Iafe0f08554d8844acb60ef9fdd1fce4594459aac
This commit is contained in:
Moh'd Khier Abualruz 2023-05-02 23:45:36 +02:00 committed by bwang
parent b1688baeb5
commit fef0ced503

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;