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

[a11y]: Checkbox does not submit form on enter #2958

Closed
hauptrolle opened this issue Feb 1, 2024 · 3 comments · Fixed by #2962
Closed

[a11y]: Checkbox does not submit form on enter #2958

hauptrolle opened this issue Feb 1, 2024 · 3 comments · Fixed by #2962
Assignees

Comments

@hauptrolle
Copy link

hauptrolle commented Feb 1, 2024

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

For example: v2.0.0-alpha.4 (but also occurs in latest stable version)

What browser are you using?

Chrome

Describe your issue

The current implementation does not support to submit the form on enter. (The components works)
Example from the docs:

import { Checkbox } from '@headlessui/react'
import { useState } from 'react'

function Example() {
  const [enabled, setEnabled] = useState(true)

  return (
    <form action="/notification-settings" method="post">
      <Checkbox
        checked={enabled}
        onChange={setEnabled}
        name="notifications"
        className="group block size-4 rounded border bg-white data-[checked]:bg-blue-500"
      >
        <svg className="stroke-white opacity-0 group-data-[checked]:opacity-100" viewBox="0 0 14 14" fill="none">
          <path d="M3 8L6 11L11 3.5" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" />
        </svg>
      </Checkbox>
      <button>Submit</button>
    </form>
  )
}
@hauptrolle hauptrolle changed the title [a11y]: Checkbox submit form on enter [a11y]: Checkbox does not submit form on enter Feb 1, 2024
@RobinMalfait RobinMalfait self-assigned this Feb 2, 2024
@RobinMalfait
Copy link
Member

Hey!

This should be fixed by #2962, and will be available in the next release.

You can already try it using:

  • npm install @headlessui/react@insiders.

@hauptrolle
Copy link
Author

@RobinMalfait Wow, thank you very much for fixing this so fast!
Any plans when the next release will be released?

@reinink
Copy link
Member

reinink commented Feb 6, 2024

Hey just a heads up that we noticed today that our insiders builds were broken. If you now try and install the latest insiders you should get this updated checkbox behavior 👍

npm install @headlessui/react@insiders

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 a pull request may close this issue.

3 participants