Fire a simluated window resize event when toggling limited width

Bug: T328121
Change-Id: I07695bb359ce849a80e8839744511a6f74a4320f
This commit is contained in:
Ed Sanders 2023-01-27 11:29:59 +00:00 committed by David Lynch
parent c4c79b557a
commit 50c8d1631e

View file

@ -24,6 +24,16 @@ function init() {
toggle.addEventListener( 'click', function () {
features.toggle( LIMITED_WIDTH_FEATURE_NAME );
setDataAttribute( toggle );
// Fire a simulated window resize event (T328121)
let event;
if ( typeof Event === 'function' ) {
event = new Event( 'resize' );
} else {
// IE11
event = window.document.createEvent( 'UIEvents' );
event.initUIEvent( 'resize', true, false, window, 0 );
}
window.dispatchEvent( event );
} );
}