Skip to content

Commit

Permalink
Update selected item on host property change
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-fix committed Jun 27, 2018
1 parent 6c78619 commit 2b2569e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/vaadin-dropdown-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<dom-module id="vaadin-dropdown-menu-text-field">
<script>
(function() {
let memoizedTemplate;
let memorizedTemplate;
/**
* The text-field element.
*
Expand All @@ -86,21 +86,21 @@
}

static get template() {
if (!memoizedTemplate) {
if (!memorizedTemplate) {
// Clone the superclass template
memoizedTemplate = super.template.cloneNode(true);
memorizedTemplate = super.template.cloneNode(true);

// Create a slot for the value element
const slot = document.createElement('slot');
slot.setAttribute('name', 'value');

// Insert the slot before the text-field
const input = memoizedTemplate.content.querySelector('input');
const input = memorizedTemplate.content.querySelector('input');

input.parentElement.replaceChild(slot, input);
slot.appendChild(input);
}
return memoizedTemplate;
return memorizedTemplate;
}

get focusElement() {
Expand Down Expand Up @@ -370,6 +370,15 @@
const template = this.querySelector('template');
this._overlayElement.template = template;
if (this._overlayElement.content) {
const origForwardHostProp = this._overlayElement._instance && this._overlayElement._instance.forwardHostProp;

this._overlayElement._instance.forwardHostProp = (...args) => {
origForwardHostProp.apply(this._overlayElement._instance, args);
setTimeout(() => {
this._updateValueSlot();
});
};

this._menuElement = Array.from(this._overlayElement.content.children).filter(element => element.localName !== 'style')[0];

if (this._menuElement) {
Expand Down

0 comments on commit 2b2569e

Please sign in to comment.