feat(select-rich): give invoker access .to hostElement

This commit is contained in:
Thijs Louisse 2022-03-15 19:13:01 +01:00
parent a64c552b61
commit 5fc39bed09
2 changed files with 18 additions and 13 deletions

View file

@ -5,6 +5,7 @@ import { css, html, SlotMixin } from '@lion/core';
* @typedef {import('@lion/core').CSSResult} CSSResult
* @typedef {import('@lion/core').TemplateResult} TemplateResult
* @typedef {import('@lion/listbox').LionOption} LionOption
* @typedef {import('@lion/select-rich').LionSelectRich} LionSelectRich
*/
/**
@ -32,19 +33,10 @@ export class LionSelectInvoker extends SlotMixin(LionButton) {
static get properties() {
return {
...super.properties,
selectedElement: {
type: Object,
},
readOnly: {
type: Boolean,
reflect: true,
attribute: 'readonly',
},
singleOption: {
type: Boolean,
reflect: true,
attribute: 'single-option',
},
selectedElement: { type: Object },
hostElement: { type: Object },
readOnly: { type: Boolean, reflect: true, attribute: 'readonly' },
singleOption: { type: Boolean, reflect: true, attribute: 'single-option' },
};
}
@ -61,6 +53,9 @@ export class LionSelectInvoker extends SlotMixin(LionButton) {
};
}
/**
* @configure OverlayMixin
*/
get _contentWrapperNode() {
return /** @type {ShadowRoot} */ (this.shadowRoot).getElementById('content-wrapper');
}
@ -78,6 +73,13 @@ export class LionSelectInvoker extends SlotMixin(LionButton) {
* @type {LionOption | null}
*/
this.selectedElement = null;
/**
* The LionSelectRich element this invoker is part of. Will be set on connectedCallback of
* LionSelectRich
* @type {LionSelectRich | null}
*/
this.hostElement = null;
/**
* When the connected LionSelectRich instance has only one option,
* this should be reflected in the invoker as well

View file

@ -140,6 +140,9 @@ export class LionSelectRich extends SlotMixin(ScopedElementsMixin(OverlayMixin(L
super.connectedCallback();
this._invokerNode.selectedElement =
this.formElements[/** @type {number} */ (this.checkedIndex)];
this._invokerNode.hostElement = this;
this.__setupInvokerNode();
this.__toggleInvokerDisabled();
this.addEventListener('keyup', this.__onKeyUp);