evidence icon indicating copy to clipboard operation
evidence copied to clipboard

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

Open jcalfee opened this issue 11 months ago • 3 comments

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 avatar Jan 09 '25 13:01 jcalfee

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.

jcalfee avatar Jan 09 '25 14:01 jcalfee

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

archiewood avatar Jan 09 '25 15:01 archiewood

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.

jcalfee avatar Jan 10 '25 18:01 jcalfee