Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ButtonGroupItem(s) with the same name are not reactivity bound #2989

Open
jcalfee opened this issue Jan 9, 2025 · 3 comments
Open
Labels
bug Something isn't working to-review Evidence team to review

Comments

@jcalfee
Copy link

jcalfee commented Jan 9, 2025

Describe the bug

Unlike the <Checkbox />, ButtonGroup's with the same name do not remain consistent when they are changed (are not reactive).

It is very useful to repeat the same set of filter components directly above the charts and Data Tables they apply to ("display components"). This really helps reading the page and works nicely when nesting components under the Accordion where some accordion may be shown and some hidden. Because one query may feed multiple charts and tables (efficiency and abstraction) it is important that the like named filter components maintain the same state so this reflect the same data shown in the display components.

Steps to Reproduce

Include more than one ButtonGroup with the same name on a page:

# Not reactively bound by name

<ButtonGroup
  title="Button group"
  name=bg
>
  <ButtonGroupItem valueLabel="One" value="1" default />
  <ButtonGroupItem valueLabel="Two" value="2" />
</ButtonGroup>

<ButtonGroup
  title="Button group"
  name=bg
>
  <ButtonGroupItem valueLabel="One" value="1" default />
  <ButtonGroupItem valueLabel="Two" value="2" />
</ButtonGroup>

# Reactively bound by name

<Checkbox name=chk_box defaultValue=true title="Check one"/>

<Checkbox name=chk_box defaultValue=true title="Also check on"/>

Logs

System Info

@evidence-dev/evidence: ^40.0.2

Severity

annoyance

Additional Information, or Workarounds

No response

@jcalfee jcalfee added bug Something isn't working to-review Evidence team to review labels Jan 9, 2025
@jcalfee
Copy link
Author

jcalfee commented Jan 9, 2025

I noticed that the sets of <Checkbox/>s got out of sync when one set of checkboxes with "name" was hidden via an Accordion and the other set with the same "name" was not hidden then changed.

@archiewood
Copy link
Member

Inputs are expected to have unique names, if you use multiple inputs with the same name, you may get undesirable behavior.

@jcalfee
Copy link
Author

jcalfee commented Jan 10, 2025

Yes, I do see inconsistent behavior. Thank you. I noticed it appeared to work in once case and found that to be a nice feature as I detailed above and my reasoning. I guess my ideas of features and consistency are not needed here. I'll refrain from bringing up stuff like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working to-review Evidence team to review
Projects
None yet
Development

No branches or pull requests

2 participants