-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Create new folder on enter in media picker #20648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,6 +136,15 @@ export class UmbMediaPickerFolderPathElement extends UmbLitElement { | |
| this.dispatchEvent(new UmbChangeEvent()); | ||
| } | ||
|
|
||
| #onKeypress(e: UUIInputEvent) { | ||
| if (e.key === 'Enter') { | ||
| requestAnimationFrame(() => { | ||
| const element = this.getHostElement().shadowRoot!.querySelector('#new-folder') as UUIInputElement; | ||
| element.blur(); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| override render() { | ||
| return html`<div id="path"> | ||
| ${repeat( | ||
|
|
@@ -154,8 +163,12 @@ export class UmbMediaPickerFolderPathElement extends UmbLitElement { | |
| label="enter a name" | ||
| value="new folder name" | ||
| @blur=${this.#addFolder} | ||
| @keypress=${this.#onKeypress} | ||
| style="margin-left: var(--uui-size-2);" | ||
|
||
| auto-width></uui-input>` | ||
| : html`<uui-button label="add folder" compact @click=${this.#focusFolderInput}>+</uui-button>`} | ||
| : html`<uui-button label="add folder" compact @click=${this.#focusFolderInput}> | ||
| <uui-icon name="icon-add" style="--uui-icon-color:inherit;"></uui-icon> | ||
|
||
| </uui-button>`} | ||
| </div>`; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter type should be
KeyboardEventinstead ofUUIInputEvent. Thekeyproperty is not available onUUIInputEvent, which will cause a runtime error. Change the parameter type toKeyboardEvent.