cschroeter / park-ui

Beautifully designed components built with Ark UI and Panda CSS that work with a variety of JS frameworks.
https://park-ui.com
MIT License
1.74k stars 75 forks source link

Add a way to configure Switch component tabIndex #435

Open punkpeye opened 2 months ago

punkpeye commented 2 months ago

I want to set tabIndex={-1} on a button associated with a switch component. Appears like there is no way of doing that at the moment. I tried:

<Switch
  checked={chatSession.synced}
  onChange={() => {
    const formData = new FormData();

    formData.append('synced', String(!chatSession.synced));

    fetcher.submit(formData, {
      action: getPath('/api/chat/:uid/update-synced', {
        uid: chatSession.uid,
      }),
      method: 'post',
    });
  }}
  size="md"
  tabIndex={-1}
>
  test
</Switch>

But the value does not propagate to the button.

My use case is that the equivalent functionality is provided through other means for accessibility, and this switch button is purely for mouse interactions.

punkpeye commented 2 months ago

ah, after some troubleshooting, I realized it is not the button, but the hidden checkbox.

Patching the code to have:

<StyledSwitch.HiddenInput tabIndex={-1} />

fixed my issue. so I guess this is non-issue for me, but something that should still be addressed in the generated code.