From 098c73210055e9a91b1c897c776293ff6b786644 Mon Sep 17 00:00:00 2001 From: Niels Grewe Date: Mon, 5 Jan 2015 10:48:10 +0100 Subject: [PATCH 1/2] Allow elements within the dropdown overlay to specify an attribute (`core-dropdown-keep') that prevents them from being evaluated for closing the dropdown on tap. This is useful for instance if you have a search form, etc. within the dropdown that you want the user to be able to tap on without closing the menu. --- core-dropdown-base.html | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/core-dropdown-base.html b/core-dropdown-base.html index f54abd4..3222a58 100644 --- a/core-dropdown-base.html +++ b/core-dropdown-base.html @@ -41,6 +41,18 @@ }, + + /** + * This specifies the name of the attribute that can be set on + * elements within the dropdown to prevent them from closing the + * dropdown on tap. + * + * @attribute dropdownKeepAttribute + * @type string + * @default 'core-dropdown-keep' + */ + dropdownKeepAttribute: 'core-dropdown-keep', + eventDelegates: { 'tap': 'toggleOverlay' }, @@ -107,7 +119,13 @@ this.opened = !!e.detail; }, - toggleOverlay: function() { + toggleOverlay: function(e) { + if (this.opened && + this.dropdownKeepAttribute && + e.target && e.target.hasAttribute(this.dropdownKeepAttribute)) + { + return; + } this.opened = !this.opened; } From 0fc1f0e49d7480c9b9b756417d568f757b8a624d Mon Sep 17 00:00:00 2001 From: Niels Grewe Date: Mon, 5 Jan 2015 10:52:48 +0100 Subject: [PATCH 2/2] Format fixup --- core-dropdown-base.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core-dropdown-base.html b/core-dropdown-base.html index 3222a58..508a6fa 100644 --- a/core-dropdown-base.html +++ b/core-dropdown-base.html @@ -43,9 +43,9 @@ /** - * This specifies the name of the attribute that can be set on - * elements within the dropdown to prevent them from closing the - * dropdown on tap. + * This specifies the name of the attribute that can be set on + * elements within the dropdown to prevent them from closing the + * dropdown on tap. * * @attribute dropdownKeepAttribute * @type string