Fix: Enter key in bulk metadata edit triggers form submit instead of adding a genre (#1234)

This commit is contained in:
Aditya Chandel
2025-09-28 15:56:31 -06:00
committed by GitHub
parent c23a626b7c
commit 2f5a71683a
2 changed files with 11 additions and 1 deletions
@@ -34,7 +34,7 @@
Checking <strong>Clear</strong> will remove that field’s metadata from <strong>all selected books</strong>.
</div>
<form [formGroup]="metadataForm" (ngSubmit)="onSubmit()" class="flex flex-col gap-4 w-full p-4">
<form [formGroup]="metadataForm" (ngSubmit)="onSubmit()" (keydown)="onFormKeydown($event)" class="flex flex-col gap-4 w-full p-4">
<div class="flex flex-col gap-2">
<label for="authors" class="flex items-center justify-between gap-2">
@@ -101,6 +101,16 @@ export class BulkMetadataUpdateComponent implements OnInit {
}
}
onFormKeydown(event: KeyboardEvent): void {
if (event.key === 'Enter') {
if ((event.target as HTMLElement)?.tagName === 'BUTTON' &&
(event.target as HTMLButtonElement)?.type === 'submit') {
return;
}
event.preventDefault();
}
}
onSubmit(): void {
if (!this.metadataForm.valid) return;