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.63k stars 71 forks source link

[Radio Group] component cannot be selected #328

Closed calloc134 closed 2 months ago

calloc134 commented 4 months ago

Thank you for the wonderful UI library.

Issue

The radio group component cannot be selected. In detail, the absence of an input element prevents the component from functioning as a radio button.

Temporary Solution

Use the ItemHiddenInput component from @ark-ui.

import * as RadioGroup from "~/components/ui/radio-group";
import { RadioGroup as RadioGroupArk } from "@ark-ui/react/radio-group";

...

  <RadioGroup.Root name="process">
    {options.map((option) => (
      <RadioGroup.Item
        key={option.value}
        value={option.value}
      >
        <RadioGroup.ItemControl />
        <RadioGroup.ItemText>{option.label}</RadioGroup.ItemText>
        <RadioGroupArk.ItemHiddenInput />
      </RadioGroup.Item>
    ))}
  </RadioGroup.Root>
...

Fundamental Solution

Create an ItemHiddenInput component in park-ui. The code is as follows.

(radio-group.tsx)
...
export const ItemHiddenInput = withContext<
  HTMLInputElement,import { ItemHiddenInput } from "node_modules/@ark-ui/react/dist/components/radio-group/radio-group";
  Assign<JsxStyleProps, RadioGroup.ItemHiddenInputProps>
>(RadioGroup.ItemHiddenInput, "itemHiddenInput");
...

In making this change, it is necessary to correct the type of context, which requires modifications to the recipe.

May I create a PR for this issue? Also, if you have any advice, please let me know.

QWu4xYV commented 3 months ago

Also running into this issue. Thanks for reporting it, @calloc134 ; the report made it much easier to find the solution.

Minor suggestion: use

import { RadioGroupItemHiddenInput } from '@ark-ui/react'

instead of

import { ItemHiddenInput } from "node_modules/@ark-ui/react/dist/components/radio-group/radio-group";

calloc134 commented 3 months ago

Can I help you with anything? May I assist you in investigating the cause of this issue?

coopbri commented 3 months ago

Related: #325

cschroeter commented 2 months ago

@calloc134

HiddenInput was missing. Should be fixed by now