material-components / material-components/material-web
Cannot cancel a dialog with a required field in an illegal state
Nobody has claimed this yet.
- Dominant language
- SCSS
- Stars
- 11.3k
- Forks
- 1.1k
- Avg merge
- 20h 28m
- Merged PRs (30d)
- 13
Description
What is affected?
Component
Description
Expect to be able to set up a form as so:
<md-dialog open>
<form
slot="content"
id="email-dialog-form"
method="dialog">
<md-filled-text-field
id="email-dialog-input"
label="Email address"
type="email"
required>
</md-filled-text-field>
</form>
<div slot="actions">
<md-text-button
value="cancel"
form="email-dialog-form">
Cancel
</md-text-button>
<md-text-button
value="ok"
form="email-dialog-form">
OK
</md-text-button>
</div>
</md-dialog>
And that the user can cancel it without filling in the required field.
From the documentation and demos it's unclear how this could be arranged or whether it's possible.
Reproduction
Workaround
Need to manually invoke validation and prevent form closure on a submit action. Maybe there are other alternatives.
Is this a regression?
No or unsure. This never worked, or I haven't tried before.
Affected versions
1.0.1
Browser/OS/Node environment
Tested on Chrome 119.0.6045.159.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Lit playground reproduction and the dialog component behavior around the form's method="dialog" and required email field. Verify how the Cancel and OK buttons submit the form; done means Cancel can close the dialog without satisfying the required field while OK still validates it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100