DEV: adds expandedOnInsert option to sk (#19870)
Allows to display a select-kit component expanded by default. Usage: ``` <SingleSelect @value={{this.value}} @content={{this.content}} @options={{hash expandedOnInsert=true}} /> ```
This commit is contained in:
parent
076b3a6514
commit
f525f722ea
|
@ -411,4 +411,17 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
|
||||||
|
|
||||||
assert.ok(header.bottom > body.top, "it correctly offsets the body");
|
assert.ok(header.bottom > body.top, "it correctly offsets the body");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("options.expandedOnInsert", async function (assert) {
|
||||||
|
setDefaultState(this);
|
||||||
|
await render(hbs`
|
||||||
|
<SingleSelect
|
||||||
|
@value={{this.value}}
|
||||||
|
@content={{this.content}}
|
||||||
|
@options={{hash expandedOnInsert=true}}
|
||||||
|
/>
|
||||||
|
`);
|
||||||
|
|
||||||
|
assert.dom(".single-select.is-expanded").exists();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -188,6 +188,14 @@ export default Component.extend(
|
||||||
this.handleDeprecations();
|
this.handleDeprecations();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
didInsertElement() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
if (this.selectKit.options.expandedOnInsert) {
|
||||||
|
this._open();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
click(event) {
|
click(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
@ -296,6 +304,7 @@ export default Component.extend(
|
||||||
desktopPlacementStrategy: null,
|
desktopPlacementStrategy: null,
|
||||||
hiddenValues: null,
|
hiddenValues: null,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
expandedOnInsert: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
autoFilterable: computed("content.[]", "selectKit.filter", function () {
|
autoFilterable: computed("content.[]", "selectKit.filter", function () {
|
||||||
|
|
Loading…
Reference in New Issue