Skip to content

Make pressing enter submit instance resize modal form - #2586

Merged
david-crespo merged 3 commits into
mainfrom
instance-resize-fix
Nov 28, 2024
Merged

david-crespo merged 3 commits into
mainfrom
instance-resize-fix

Conversation

@david-crespo

Copy link
Copy Markdown
Collaborator

Closes #2585

Modal.Footer has more lines of props than lines of code. Not my favorite.

@vercel

vercel Bot commented Nov 27, 2024 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Nov 28, 2024 4:13am

Comment thread app/ui/lib/Modal.tsx Resolved
Comment thread app/ui/lib/Modal.tsx
cancelText?: string
disabled?: boolean
} & MergeExclusive<{ formId: string }, { onAction: () => void }>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yoooo MergeExclusive is my new best friend

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯

@david-crespo
david-crespo enabled auto-merge (squash) November 28, 2024 04:13
@david-crespo
david-crespo merged commit d7fd3c4 into main Nov 28, 2024
@david-crespo
david-crespo deleted the instance-resize-fix branch November 28, 2024 04:22
david-crespo added a commit that referenced this pull request Nov 2, 2026
While looking at #3417, I found that the Link silo and Link pool modals
use a click handler to wire up their submit buttons. This means they
don't work like forms are supposed to, e.g., pressing Enter doesn't
submit the form. In this PR we hook up the submit buttons through
`formId`, which makes them the submit button of the `<form>` tag. This
matches other modal forms, like instance resize (#2586). On its own this
only makes Enter work from the "Make default" checkbox, because the
combobox swallows Enter. #3417 (or the alternative I'm about to PR)
makes it work from the picker too.

While looking at _that_, I asked 🤖 if any other modal forms are hooked
up wrong, and it pointed me to the attach floating IP modal in instance
create, which _does_ have a `<form>`, but should not because it
technically renders inside the instance create form, and you can't have
a form inside a form. This caused an actual bug:

On Enter, Headless UI's `ListboxButton` submits the nearest form, and
React bubbled that submit through the modal portal to the instance
create form, so pressing Enter on the closed listbox submits the whole
form. Removing the `<form>` fixes it. In this case we have to keep the
submit button a click handler. We could add an explicit enter key
handler, but it's not worth it.

This branch was successfully deployed

1 active deployment
Preview — 3525cc38 Deployed Nov 28, 2024 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Instance resize modal: enter doesn't submit the form

2 participants