chakra-ui / ark

Ark UI is a headless UI library with over 45+ components designed to build scalable Design Systems that works for a wide range of JS frameworks.
https://ark-ui.com
MIT License
3.79k stars 107 forks source link

Switch - Toggle not working with "Enter" key #2946

Closed thevipinmishra closed 1 month ago

thevipinmishra commented 1 month ago

Description

According to the docs, "Switch" toggles on both the "Space" and "Enter" keys.

However, it only works with "Space" and not the other one.

I confirmed it with ark-ui's own Switch component.

Link to Reproduction (or Detailed Explanation)

https://ark-ui.com/react/docs/components/switch

Steps to Reproduce

  1. Vist the "Switch" component page.

  2. Focus on the preview component.

  3. Try toggling it with "Enter" key.

Ark UI Version

4.1.0

Framework

Browser

Google Chrome Dev

Additional Information

No response

segunadebayo commented 1 month ago

This is by design. The switch is built on top of the checkbox component which only toggles with the space key or pointer click.

The enter key is reserved for form submissions.

thevipinmishra commented 1 month ago

The enter key is reserved for form submissions.

Thanks for the quick response @segunadebayo!

I only mentioned it because it was mentioned in the docs. I think we can remove it then!?

image