Skip to content

Commit

Permalink
Fix focusing of the input
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-fix committed Feb 27, 2018
1 parent efa0ebf commit 3cf7907
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/vaadin-date-picker-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,6 @@
value: true
},

_cleared: Boolean,

_focusOverlayOnOpen: Boolean
};
}
Expand Down Expand Up @@ -342,12 +340,9 @@
* Opens the dropdown.
*/
open() {
if (!this.disabled && !this.readonly && !this._cleared) {
if (!this.disabled && !this.readonly) {
this.$.overlay.opened = true;
this._updateAlignmentAndPosition();
} else if (this._cleared) {
this._inputElement.focus();
this._cleared = false;
}
}

Expand Down
13 changes: 10 additions & 3 deletions src/vaadin-date-picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
part="text-field"
>
<slot name="prefix" slot="prefix"></slot>
<div part="clear-button" slot="suffix" on-touchstart="_preventDefault" on-tap="_clear" role="button" aria-label$="[[i18n.clear]]"></div>
<div part="clear-button" slot="suffix" on-touchend="_clearTouchend" on-click="_clear" role="button" aria-label$="[[i18n.clear]]"></div>
<div part="toggle-button" slot="suffix" on-tap="_toggle" role="button" aria-label$="[[i18n.calendar]]" aria-expanded$="[[_getAriaExpanded(opened)]]"></div>
</vaadin-text-field>

Expand Down Expand Up @@ -268,10 +268,17 @@
}
}

_clear(e) {
this._cleared = e.target === this.shadowRoot.querySelector('[part~="clear-button"]');
_clear() {
this.value = '';
this.validate();
this.focus();
Polymer.Gestures.prevent('tap');
}

_clearTouchend(e) {
this._clear();
e.preventDefault();
Polymer.Gestures.prevent('tap');
}

_toggle(e) {
Expand Down

0 comments on commit 3cf7907

Please sign in to comment.