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:
Joffrey JAFFEUX 2023-01-13 16:13:13 +01:00 committed by GitHub
parent 076b3a6514
commit f525f722ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -411,4 +411,17 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
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();
});
});

View File

@ -188,6 +188,14 @@ export default Component.extend(
this.handleDeprecations();
},
didInsertElement() {
this._super(...arguments);
if (this.selectKit.options.expandedOnInsert) {
this._open();
}
},
click(event) {
event.preventDefault();
event.stopPropagation();
@ -296,6 +304,7 @@ export default Component.extend(
desktopPlacementStrategy: null,
hiddenValues: null,
disabled: false,
expandedOnInsert: false,
},
autoFilterable: computed("content.[]", "selectKit.filter", function () {