Skip to content

Conversation

@buhodev
Copy link
Contributor

@buhodev buhodev commented Nov 17, 2025

fixes: #1894

@changeset-bot
Copy link

changeset-bot bot commented Nov 17, 2025

🦋 Changeset detected

Latest commit: 70d9594

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
bits-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Nov 17, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
bits-ui ✅ Ready (View Log) Visit Preview 70d9594

@huntabyte
Copy link
Owner

Could you not just pass type="submit" to the checkbox?

@huntabyte
Copy link
Owner

I think we just don't prevent default when enter is pressed if type="submit" seems like a simpler fix here

@huntabyte
Copy link
Owner

huntabyte commented Nov 19, 2025

Ah but I guess that would still strigger a "click" event on the button thus changing the state, so this solution might be best after all. I do still think we should detect the type prop and only submit if it's type="submit"

@buhodev
Copy link
Contributor Author

buhodev commented Nov 19, 2025

Ah but I guess that would still strigger a "click" event on the button thus changing the state, so this solution might be best after all. I do still think we should detect the type prop and only submit if it's type="submit"

yes exactly, the click event is detected instead. ok I will update the code to reflect that change

@buhodev
Copy link
Contributor Author

buhodev commented Nov 19, 2025

wait, don't you think that having the type="submit" is irrelevant for this usecase? in svelte it's possible to submit the form when pressing "Enter" on a checkbox even without the type="submit".

demo

@huntabyte
Copy link
Owner

wait, don't you think that having the type="submit" is irrelevant for this usecase? in svelte it's possible to submit the form when pressing "Enter" on a checkbox even without the type="submit".

You're comparing an <input type="checkbox" /> to a Bits UI checkbox which renders a <button> to support tri-state.

@buhodev
Copy link
Contributor Author

buhodev commented Nov 20, 2025

Done, any other suggestion?

btw, do you think other components should have the same behaviour? e.g. the radio-group, the switch, etc

@huntabyte huntabyte merged commit 9ca9ae6 into huntabyte:main Jan 3, 2026
6 checks passed
@github-actions github-actions bot mentioned this pull request Jan 3, 2026
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 this pull request may close these issues.

Mirror vanilla html input of type checkbox behaviour for submitting forms

2 participants