From 29c00fc1000f6702ed26860868037976daeaf255 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 15 Mar 2022 13:41:06 +0000 Subject: [PATCH] MDL-74214 forms: re-calculate calendar panel zIndex each time. The previous iteration only calculated it's zIndex value on initial load. This meant that any nodes added subsequent to this would not be taken into account (e.g. modal forms). --- .../moodle-form-dateselector-debug.js | 20 ++++++++++--------- .../moodle-form-dateselector-min.js | 4 ++-- .../moodle-form-dateselector.js | 20 ++++++++++--------- .../yui/src/dateselector/js/dateselector.js | 20 ++++++++++--------- 4 files changed, 35 insertions(+), 29 deletions(-) diff --git a/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-debug.js b/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-debug.js index d4cb9edeecf..af87380dbbb 100644 --- a/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-debug.js +++ b/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-debug.js @@ -80,16 +80,18 @@ M.form.dateselector = { this.panel.render(document.body); // Determine the correct zindex by looking at all existing dialogs and menubars in the page. - var highestzindex = 0; - Y.all(DIALOGUE_SELECTOR + ', ' + MENUBAR_SELECTOR + ', ' + DOT + HAS_ZINDEX).each(function(node) { - var zindex = this.findZIndex(node); - if (zindex > highestzindex) { - highestzindex = zindex; - } + this.panel.on('focus', function() { + var highestzindex = 0; + Y.all(DIALOGUE_SELECTOR + ', ' + MENUBAR_SELECTOR + ', ' + DOT + HAS_ZINDEX).each(function(node) { + var zindex = this.findZIndex(node); + if (zindex > highestzindex) { + highestzindex = zindex; + } + }, this); + // Only set the zindex if we found a wrapper. + var zindexvalue = (highestzindex + 1).toString(); + Y.one('#dateselector-calendar-panel').setStyle('zIndex', zindexvalue); }, this); - // Only set the zindex if we found a wrapper. - var zindexvalue = (highestzindex + 1).toString(); - Y.one('#dateselector-calendar-panel').setStyle('zIndex', zindexvalue); this.panel.on('heightChange', this.fix_position, this); diff --git a/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-min.js b/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-min.js index a4f95511e90..de09d4267b0 100644 --- a/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-min.js +++ b/lib/form/yui/build/moodle-form-dateselector/moodle-form-dateselector-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-form-dateselector",function(o,e){var t,a;o.mix(o.Node.prototype,{firstOptionValue:function(){return"select"===this.get("nodeName").toLowerCase()&&this.one("option").get("value")},lastOptionValue:function(){return"select"===this.get("nodeName").toLowerCase()&&this.all("option").item(this.optionSize()-1).get("value")},optionSize:function(){return"select"===this.get("nodeName").toLowerCase()&&parseInt(this.all("option").size(),10)},selectedOptionValue:function(){return"select"===this.get("nodeName").toLowerCase()&&this.all("option").item(this.get("selectedIndex")).get("value")}}),M.form=M.form||{},M.form.dateselector={panel:null,calendar:null,currentowner:null,hidetimeout:null,repositiontimeout:null,init_date_selectors:function(e){null===this.panel&&this.initPanel(e),o.all(".fdate_time_selector").each(function(){e.node=this,new t(e)}),o.all(".fdate_selector").each(function(){e.node=this,new t(e)})},initPanel:function(e){var t,n;this.panel=new o.Overlay({visible:!1,bodyContent:o.Node.create('
'),id:"dateselector-calendar-panel",constrain:!0}),this.panel.render(document.body),t=0,o.all(" [role=dialog], [role=menubar], .moodle-has-zindex").each(function(e){e=this.findZIndex(e);t'),id:"dateselector-calendar-panel",constrain:!0}),this.panel.render(document.body),this.panel.on("focus",function(){var e,t=0;n.all(" [role=dialog], [role=menubar], .moodle-has-zindex").each(function(e){e=this.findZIndex(e);t highestzindex) { - highestzindex = zindex; - } + this.panel.on('focus', function() { + var highestzindex = 0; + Y.all(DIALOGUE_SELECTOR + ', ' + MENUBAR_SELECTOR + ', ' + DOT + HAS_ZINDEX).each(function(node) { + var zindex = this.findZIndex(node); + if (zindex > highestzindex) { + highestzindex = zindex; + } + }, this); + // Only set the zindex if we found a wrapper. + var zindexvalue = (highestzindex + 1).toString(); + Y.one('#dateselector-calendar-panel').setStyle('zIndex', zindexvalue); }, this); - // Only set the zindex if we found a wrapper. - var zindexvalue = (highestzindex + 1).toString(); - Y.one('#dateselector-calendar-panel').setStyle('zIndex', zindexvalue); this.panel.on('heightChange', this.fix_position, this); diff --git a/lib/form/yui/src/dateselector/js/dateselector.js b/lib/form/yui/src/dateselector/js/dateselector.js index b0ff8b3270e..5c9ca317388 100644 --- a/lib/form/yui/src/dateselector/js/dateselector.js +++ b/lib/form/yui/src/dateselector/js/dateselector.js @@ -76,16 +76,18 @@ M.form.dateselector = { this.panel.render(document.body); // Determine the correct zindex by looking at all existing dialogs and menubars in the page. - var highestzindex = 0; - Y.all(DIALOGUE_SELECTOR + ', ' + MENUBAR_SELECTOR + ', ' + DOT + HAS_ZINDEX).each(function(node) { - var zindex = this.findZIndex(node); - if (zindex > highestzindex) { - highestzindex = zindex; - } + this.panel.on('focus', function() { + var highestzindex = 0; + Y.all(DIALOGUE_SELECTOR + ', ' + MENUBAR_SELECTOR + ', ' + DOT + HAS_ZINDEX).each(function(node) { + var zindex = this.findZIndex(node); + if (zindex > highestzindex) { + highestzindex = zindex; + } + }, this); + // Only set the zindex if we found a wrapper. + var zindexvalue = (highestzindex + 1).toString(); + Y.one('#dateselector-calendar-panel').setStyle('zIndex', zindexvalue); }, this); - // Only set the zindex if we found a wrapper. - var zindexvalue = (highestzindex + 1).toString(); - Y.one('#dateselector-calendar-panel').setStyle('zIndex', zindexvalue); this.panel.on('heightChange', this.fix_position, this);