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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

md-button doesn't integrate with form data #4526

Closed
jkrems opened this issue Jul 6, 2023 · 2 comments · Fixed by #4691
Closed

md-button doesn't integrate with form data #4526

jkrems opened this issue Jul 6, 2023 · 2 comments · Fixed by #4691
Assignees

Comments

@jkrems
Copy link

jkrems commented Jul 6, 2023

I was adding an md-button to an existing form and thought it would act "just like a button with different styles". But it looks like the type=submit just emulates the behavior on a non-button element. But at least one behavior is missing from that emulation: A named submit button should show up in the form data. Example:

<form>
  <input name="txt" type="text" />
  <md-button name="btn" value="a" type="submit">Submit A</md-button>
  <md-button name="btn" value="b" type="submit">Submit B</md-button>
</form>

When submitting, I would expect btn=a or btn=b to appear in the form data, depending on which button was clicked to submit. If the form is submitted by pressing <enter> while focussing the text input field, I would expect the first submit button's value to appear in the form data.

Example (hopefully stays online): https://jsfiddle.net/au82xrv9/1/

@jkrems
Copy link
Author

jkrems commented Jul 6, 2023

It looks like there is a button inside of the custom element but it gets none of the attributes (name/value/type). Not sure if that would be the simplest fix or if there are downside to that approach.

@asyncLiz
Copy link
Collaborator

asyncLiz commented Jul 6, 2023

I just noted this yesterday while doing a review of button :)

copybara-service bot pushed a commit that referenced this issue Aug 17, 2023
Fixes #4526

PiperOrigin-RevId: 557962836
copybara-service bot pushed a commit that referenced this issue Aug 18, 2023
Fixes #4526

PiperOrigin-RevId: 557962836
copybara-service bot pushed a commit that referenced this issue Aug 18, 2023
Fixes #4526

PiperOrigin-RevId: 557962836
@asyncLiz asyncLiz self-assigned this Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants