MDL-77174 core: Modal z-index calc should ignore hidden items

When an AMD dialogue is opened from a YUI dialogue, the YUI dialogue is
not actually removed from the DOM, but was counted in z-index
calculation.

We need to stop including it otherwise nested AMD => YUI => AMD
dialogues get broken.
This commit is contained in:
Andrew Nicols 2023-03-01 20:16:52 +08:00
parent 56260354b1
commit cad1c7d008
No known key found for this signature in database
GPG key ID: 6D1E3157C8CFBF14
3 changed files with 7 additions and 2 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -644,6 +644,11 @@ export default class Modal {
items.each((index, item) => { items.each((index, item) => {
item = $(item); item = $(item);
if (!item.is(':visible')) {
// Do not include items which are not visible in the z-index calculation.
// This is important because some dialogues are not removed from the DOM.
return;
}
// Note that webkit browsers won't return the z-index value from the CSS stylesheet // Note that webkit browsers won't return the z-index value from the CSS stylesheet
// if the element doesn't have a position specified. Instead it'll return "auto". // if the element doesn't have a position specified. Instead it'll return "auto".
const itemZIndex = item.css('z-index') ? parseInt(item.css('z-index')) : 0; const itemZIndex = item.css('z-index') ? parseInt(item.css('z-index')) : 0;