Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add name and value props to button #12014

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hamideha
Copy link

@hamideha hamideha commented May 17, 2024

WHY are these changes introduced?

This PR adds name and value as valid props to the Button component (UnstyledButton included).

Shopify offers the Remix app template to quickly bootstrap apps. With Remix you can only have a single action export per route, so in order to handle multiple forms per route you need a way to distinguish between which form was submitted in the action.

The Remix docs suggests doing this by sending a form input with a value that indicates the action you want to take. Specifically, it suggests adding a name and value attribute to the submit button. With Polaris buttons, however, you can't pass a name or value. This PR allows them to be passed. Note that these props don't really do anything functionally if the button isn't used in a form to submit the form.

I should also point out that it's possible to use a hidden input <input name="hello" value="world" type="hidden" /> to solve the use case above but in my opinion name and value on the submit button have more semantic meaning and it's less code.

馃帺 checklist

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.

None yet

1 participant