feat: add Ctrl+Enter and Enter keyboard navigation to form modal
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ff6fecd39b
commit
0305f0be15
1 changed files with 23 additions and 0 deletions
|
|
@ -132,6 +132,29 @@ export class FormModal extends Modal {
|
|||
submitBtn.addEventListener('click', () => {
|
||||
this.handleSubmit();
|
||||
});
|
||||
|
||||
// Keyboard navigation
|
||||
contentEl.addEventListener('keydown', (e: KeyboardEvent) => {
|
||||
// Ctrl+Enter always submits
|
||||
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
|
||||
e.preventDefault();
|
||||
this.handleSubmit();
|
||||
return;
|
||||
}
|
||||
|
||||
// Enter on single-line inputs submits (unless in suggest dropdown)
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
const target = e.target as HTMLElement;
|
||||
if (
|
||||
target instanceof HTMLInputElement &&
|
||||
target.type !== 'textarea' &&
|
||||
!target.closest('.ff-suggest-wrapper')
|
||||
) {
|
||||
e.preventDefault();
|
||||
this.handleSubmit();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async handleSubmit(): Promise<void> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue