Skip to content

Commit

Permalink
fix(submit): textarea shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-pluto committed May 20, 2024
1 parent b50fec3 commit 06b262d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/forms/src/components/WebForms.astro
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ const clientScript = Astro.locals.forms.scriptToRun;
}

window.__enterToSubmit = function (event) {
if (event.code === 'Enter') {
const target = event.target as HTMLElement;
const isMultiLine = target instanceof HTMLTextAreaElement;

if ((isMultiLine && event.ctrlKey || !isMultiLine) && event.code === 'Enter') {
event.preventDefault();
document.getElementById((event.target as HTMLElement).getAttribute('data-submit')!)?.click();
document.getElementById(target.getAttribute('data-submit')!)?.click();
}
};

Expand Down

0 comments on commit 06b262d

Please sign in to comment.