classic-design-system icon indicating copy to clipboard operation
classic-design-system copied to clipboard

[Feat?]: add 'enter' keypress to Switch component

Open caseybaggz opened this issue 3 years ago • 1 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Summary 💡

Current Checkbox is supporting using "enter" key but Switch component does not. In order to be consistent, we need to update Switch to use the same keypress functionality:

Checkbox code: https://github.com/pluralsight/design-system/blob/master/packages/checkbox/src/react/index.tsx#L86

Examples 🌈

No response

Motivation 🔦

Improve a11y functionality and consistency.

caseybaggz avatar Jan 26 '22 21:01 caseybaggz

In native elements, only space toggles a checkbox. This is because when a form element has focus and enter is pressed, the form is submitted.

I think we should re-evaluate this approach, as well as our current checkbox in favor of removing toggle on enter functionality, knowing that there is a potentially negative impact to this. Or perhaps controlling this behavior with a flag that defaults to true to preserve existing functionality?

Rykus0 avatar Feb 28 '22 14:02 Rykus0