Skip to content

Commit

Permalink
fix: prevent unexpected field behaviour when pressing "Enter" key
Browse files Browse the repository at this point in the history
Closes #345

ExternalInput and ArrayFields have button elements which assumed the
default type "submit". This causes the buttons to be automatically
triggered when "Enter" keypress happens on other inputs of the form.

Setting their type as "button" instead, fixes the behaviour.
  • Loading branch information
jonduarte authored Mar 25, 2024
1 parent 68f97ae commit bf4f527
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/core/components/ExternalInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const ExternalInput = ({
>
<div className={getClassName("actions")}>
<button
type="button"
onClick={() => setOpen(true)}
className={getClassName("button")}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export const ArrayField = ({
<div className={getClassNameItem("actions")}>
<div className={getClassNameItem("action")}>
<IconButton
type="button"
disabled={
field.min !== undefined &&
field.min >=
Expand Down Expand Up @@ -292,6 +293,7 @@ export const ArrayField = ({
{provided.placeholder}

<button
type="button"
className={getClassName("addButton")}
disabled={
field.max !== undefined &&
Expand Down

0 comments on commit bf4f527

Please sign in to comment.