From 1b06a647770a20129d9888bb423b63eba727ea61 Mon Sep 17 00:00:00 2001 From: Tony Mobily Date: Thu, 20 Oct 2016 14:53:32 +0800 Subject: [PATCH 1/2] Added auto-validate --- paper-dropdown-menu.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/paper-dropdown-menu.html b/paper-dropdown-menu.html index 06f4ab8..bc23006 100644 --- a/paper-dropdown-menu.html +++ b/paper-dropdown-menu.html @@ -135,6 +135,14 @@ ], properties: { + + /** + * Set to true to auto-validate the input value when it changes. + */ + autoValidate: { + type: Boolean + }, + /** * The derived "label" of the currently selected item. This value * is the `label` property on the selected item if set, or else the @@ -365,6 +373,16 @@ this._setValue(value); this._setSelectedItemLabel(value); + + if( this.autoValidate ){ + var valid; + if (this.validate) { + valid = this.validate(); + } else { + valid = this.checkValidity(); + } + this.invalid = !valid; + } }, /** From e6a712e8ddab13e2019512ea340004db83df323e Mon Sep 17 00:00:00 2001 From: Tony Mobily Date: Thu, 20 Oct 2016 14:57:03 +0800 Subject: [PATCH 2/2] Added documentation of the new property --- paper-dropdown-menu.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paper-dropdown-menu.html b/paper-dropdown-menu.html index bc23006..cb2931a 100644 --- a/paper-dropdown-menu.html +++ b/paper-dropdown-menu.html @@ -57,6 +57,11 @@ Applications can listen for the `iron-select` and `iron-deselect` events to react when options are selected and deselected. +### Validation + +If the `auto-validate` attribute is set, the element will be validated when +the selected item changes. + ### Styling The following custom properties and mixins are also available for styling: