Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby committed Mar 14, 2024
2 parents 2edff22 + ec9ce30 commit 602b82b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/comment-widget/src/base-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ export class BaseForm extends LitElement {
}
}

onKeydown(e: KeyboardEvent) {
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
const form = this.shadowRoot?.querySelector('form');
e.preventDefault();
form?.requestSubmit();
}
}

override connectedCallback(): void {
super.connectedCallback();
this.addEventListener('keydown', this.onKeydown);
}

override disconnectedCallback(): void {
super.disconnectedCallback();
this.removeEventListener('keydown', this.onKeydown);
}

override render() {
return html`
<form class="form" @submit="${this.onSubmit}">
Expand Down

0 comments on commit 602b82b

Please sign in to comment.