diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json b/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json
index e0183b2eb7..9dad6b0a0c 100644
--- a/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json
+++ b/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json
@@ -1,6 +1,6 @@
{
"name": "iron-overlay-behavior",
- "version": "1.4.0",
+ "version": "1.4.1",
"license": "http://polymer.github.io/LICENSE.txt",
"description": "Provides a behavior for making an element an overlay",
"private": true,
@@ -35,11 +35,11 @@
},
"ignore": [],
"homepage": "https://github.com/polymerelements/iron-overlay-behavior",
- "_release": "1.4.0",
+ "_release": "1.4.1",
"_resolution": {
"type": "version",
- "tag": "v1.4.0",
- "commit": "9731850e81b004723f0c1878a85479f7aa9cfda1"
+ "tag": "v1.4.1",
+ "commit": "4aefb7bc41aecef69022d6435133c430fc52d3ba"
},
"_source": "git://github.com/polymerelements/iron-overlay-behavior.git",
"_target": "^1.0.0",
diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/bower.json b/dashboard-ui/bower_components/iron-overlay-behavior/bower.json
index 04d51e1b33..805ca3ab9b 100644
--- a/dashboard-ui/bower_components/iron-overlay-behavior/bower.json
+++ b/dashboard-ui/bower_components/iron-overlay-behavior/bower.json
@@ -1,6 +1,6 @@
{
"name": "iron-overlay-behavior",
- "version": "1.4.0",
+ "version": "1.4.1",
"license": "http://polymer.github.io/LICENSE.txt",
"description": "Provides a behavior for making an element an overlay",
"private": true,
diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/demo/index.html b/dashboard-ui/bower_components/iron-overlay-behavior/demo/index.html
index c1bd1e23cb..93453d247e 100644
--- a/dashboard-ui/bower_components/iron-overlay-behavior/demo/index.html
+++ b/dashboard-ui/bower_components/iron-overlay-behavior/demo/index.html
@@ -61,6 +61,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
+
Use restore-focus-on-close to return the focus to the element that opened the overlay when it gets closed.
+
+
+
+
+
Hello world!
+
+
+
+
+
The child with autofocus gets focused when opening the overlay.
diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-behavior.html b/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-behavior.html
index 4929a393e0..e02eba15d8 100644
--- a/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-behavior.html
+++ b/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-behavior.html
@@ -128,6 +128,14 @@ context. You should place this element as a child of `` whenever possible.
value: document
},
+ /**
+ * Set to true to enable restoring of focus when overlay is closed.
+ */
+ restoreFocusOnClose: {
+ type: Boolean,
+ value: false
+ },
+
_manager: {
type: Object,
value: Polymer.IronOverlayManager
@@ -179,7 +187,7 @@ context. You should place this element as a child of `` whenever possible.
* @type {Node}
*/
get _focusNode() {
- return this._focusedChild || Polymer.dom(this).querySelector('[autofocus]') || this.__firstFocusableNode || this;
+ return this._focusedChild || Polymer.dom(this).querySelector('[autofocus]') || this;
},
/**
@@ -235,7 +243,7 @@ context. You should place this element as a child of `` whenever possible.
},
ready: function() {
- // with-backdrop need tabindex to be set in order to trap the focus.
+ // with-backdrop needs tabindex to be set in order to trap the focus.
// If it is not set, IronOverlayBehavior will set it, and remove it if with-backdrop = false.
this.__shouldRemoveTabIndex = false;
// Used for wrapping the focus on TAB / Shift+TAB.
@@ -245,7 +253,7 @@ context. You should place this element as a child of `` whenever possible.
attached: function() {
// Call _openedChanged here so that position can be computed correctly.
- if (this._callOpenedWhenReady) {
+ if (this.opened) {
this._openedChanged();
}
this._observer = Polymer.dom(this).observeNodes(this._onNodesChange);
@@ -315,7 +323,6 @@ context. You should place this element as a child of `` whenever possible.
// wait to call after ready only if we're initially open
if (!this._overlaySetup) {
- this._callOpenedWhenReady = this.opened;
return;
}
@@ -552,28 +559,29 @@ context. You should place this element as a child of `` whenever possible.
this._focusedChild = nodeToSet;
}
}
-
-/**
- * Fired after the `iron-overlay` opens.
- * @event iron-overlay-opened
- */
-
-/**
- * Fired when the `iron-overlay` is canceled, but before it is closed.
- * Cancel the event to prevent the `iron-overlay` from closing.
- * @event iron-overlay-canceled
- * @param {?Event} event The event in case the user pressed ESC or clicked outside the overlay
- */
-
-/**
- * Fired after the `iron-overlay` closes.
- * @event iron-overlay-closed
- * @param {{canceled: (boolean|undefined)}} set to the `closingReason` attribute
- */
};
/** @polymerBehavior */
Polymer.IronOverlayBehavior = [Polymer.IronA11yKeysBehavior, Polymer.IronFitBehavior, Polymer.IronResizableBehavior, Polymer.IronOverlayBehaviorImpl];
+ /**
+ * Fired after the `iron-overlay` opens.
+ * @event iron-overlay-opened
+ */
+
+ /**
+ * Fired when the `iron-overlay` is canceled, but before it is closed.
+ * Cancel the event to prevent the `iron-overlay` from closing.
+ * @event iron-overlay-canceled
+ * @param {Event} event The closing of the `iron-overlay` can be prevented
+ * by calling `event.preventDefault()`. The `event.detail` is the original event that originated
+ * the canceling (e.g. ESC keyboard event or click event outside the `iron-overlay`).
+ */
+
+ /**
+ * Fired after the `iron-overlay` closes.
+ * @event iron-overlay-closed
+ * @param {{canceled: (boolean|undefined)}} closingReason Contains `canceled` (whether the overlay was canceled).
+ */
diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-manager.html b/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-manager.html
index 094a89e115..3156f7b29a 100644
--- a/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-manager.html
+++ b/dashboard-ui/bower_components/iron-overlay-behavior/iron-overlay-manager.html
@@ -18,6 +18,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
Polymer.IronOverlayManagerClass = function() {
this._overlays = [];
+ // Used to keep track of the last focused node before an overlay gets opened.
+ this._lastFocusedNodes = [];
+
/**
* iframes have a default z-index of 100, so this default should be at least
* that.
@@ -36,7 +39,42 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return this._backdropElement;
}.bind(this)
});
- }
+
+ /**
+ * The deepest active element.
+ * returns {?Node} element the active element
+ */
+ this.deepActiveElement = null;
+ Object.defineProperty(this, 'deepActiveElement', {
+ get: function() {
+ var active = document.activeElement;
+ // document.activeElement can be null
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement
+ while (active && active.root && Polymer.dom(active.root).activeElement) {
+ active = Polymer.dom(active.root).activeElement;
+ }
+ return active;
+ }.bind(this)
+ });
+ };
+
+ /**
+ * If a node is contained in an overlay.
+ * @private
+ * @param {Node} node
+ * @returns {Boolean}
+ */
+ Polymer.IronOverlayManagerClass.prototype._isChildOfOverlay = function(node) {
+ while (node && node !== document.body) {
+ // Use logical parentNode, or native ShadowRoot host.
+ node = Polymer.dom(node).parentNode || node.host;
+ // Check if it is an overlay.
+ if (node && node.behaviors && node.behaviors.indexOf(Polymer.IronOverlayBehaviorImpl) !== -1) {
+ return true;
+ }
+ }
+ return false;
+ };
Polymer.IronOverlayManagerClass.prototype._applyOverlayZ = function(overlay, aboveZ) {
this._setZ(overlay, aboveZ + 2);
@@ -56,6 +94,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
if (newZ <= minimumZ) {
this._applyOverlayZ(overlay, minimumZ);
}
+ var element = this.deepActiveElement;
+ // If already in other overlay, don't reset focus there.
+ if (this._isChildOfOverlay(element)) {
+ element = null;
+ }
+ this._lastFocusedNodes.push(element);
};
Polymer.IronOverlayManagerClass.prototype.removeOverlay = function(overlay) {
@@ -63,6 +107,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
if (i >= 0) {
this._overlays.splice(i, 1);
this._setZ(overlay, '');
+
+ var node = this._lastFocusedNodes[i];
+ // Focus only if still contained in document.body
+ if (overlay.restoreFocusOnClose && node && Polymer.dom(document.body).deepContains(node)) {
+ node.focus();
+ }
+ this._lastFocusedNodes.splice(i, 1);
}
};
diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/test/iron-overlay-behavior.html b/dashboard-ui/bower_components/iron-overlay-behavior/test/iron-overlay-behavior.html
index 8dcc52968d..69d0c73423 100644
--- a/dashboard-ui/bower_components/iron-overlay-behavior/test/iron-overlay-behavior.html
+++ b/dashboard-ui/bower_components/iron-overlay-behavior/test/iron-overlay-behavior.html
@@ -24,6 +24,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
+