Add name and value props to button #12014
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
This PR adds
name
andvalue
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
andvalue
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 opinionname
andvalue
on the submit button have more semantic meaning and it's less code.馃帺 checklist