Skip to content
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

Add support to press Enter & Esc when creating new things #94

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion blocks/browse/da-browse/da-browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ export default class DaBrowse extends LitElement {
return null;
}

handleKeyCommands(event) {
if (event.key === 'Enter') {
event.preventDefault();
this.handleSave();
} else if (event.key === 'Escape') {
this.resetCreate();
}
}

renderNew() {
return html`
<div class="da-actions-create ${this._createShow}">
Expand All @@ -257,7 +266,7 @@ export default class DaBrowse extends LitElement {
</li>
</ul>
<div class="da-actions-input-container">
<input type="text" class="da-actions-input" placeholder="Name" @input=${this.handleNameChange} .value=${this._createName} />
<input type="text" class="da-actions-input" placeholder="Name" @input=${this.handleNameChange} .value=${this._createName} @keydown=${this.handleKeyCommands}/>
<button class="da-actions-button" @click=${this.handleSave}>Create ${this._createType}</button>
<button class="da-actions-button da-actions-button-cancel" @click=${this.resetCreate}>Cancel</button>
</div>
Expand Down
Loading