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

required attribute not working in prompt modals #699

Closed
rakuzen25 opened this issue Dec 16, 2022 · 1 comment · Fixed by #712
Closed

required attribute not working in prompt modals #699

rakuzen25 opened this issue Dec 16, 2022 · 1 comment · Fixed by #712
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@rakuzen25
Copy link
Contributor

Current Behavior

The required attribute on the text input element in prompt modals is not being enforced.

Steps To Reproduce

  1. Go to the demo page and open a "Prompt" modal.
  2. Delete everything in the text input and submit.
  3. Modal closes despite having required set.

Anything else?

{:else if $modalStore[0].type === 'prompt'}
<!-- Template: Prompt -->
<input class="modal-prompt-input" type="text" bind:value={promptValue} required />
<!-- prettier-ignore -->
<footer class="modal-footer {regionFooter}">
<button class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
<button class="btn {buttonPositive}" on:click={onPromptSubmit}>{buttonTextSubmit}</button>
</footer>

L176 perhaps needs to be wrapped in a form.

By the way, is it a good idea to submit on enter? It feels more intuitive, but I'm not sure if it fails to comply with accessibility standards.

@rakuzen25 rakuzen25 added the bug Something isn't working label Dec 16, 2022
@endigo9740 endigo9740 added the help wanted Extra attention is needed label Dec 16, 2022
@endigo9740 endigo9740 linked a pull request Dec 16, 2022 that will close this issue
@endigo9740
Copy link
Contributor

endigo9740 commented Dec 16, 2022

FYI I went about this a little bit different than your suggestion. Instead of trying to make it a proper form, I just made it so the submit button is set to disabled if the value is not present. This provides the desired result.

<button class="btn {buttonPositive}" on:click={onPromptSubmit} disabled={!promptValue}>

@endigo9740 endigo9740 self-assigned this Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants