spectrum-web-components icon indicating copy to clipboard operation
spectrum-web-components copied to clipboard

[Bug]: Removing `selected` attribute from sp-action-group leads to console error

Open adixon-adobe opened this issue 1 year ago • 1 comments

Code of conduct

  • [X] I agree to follow this project's code of conduct.

Impacted component(s)

sp-action-group

Expected behavior

Removing the selected attribute from sp-action-group should have the same behavior as not setting it in the first place, and default to an empty array. It shouldn't lead to a console error.

Actual behavior

It looks like there's a logic error in the code such that the initial default value isn't reset in this case though. It does look like ActionGroup.ts is tracking an _selected variable, but not resetting it to the default if the selected attribute is removed.

Screenshots

No response

What browsers are you seeing the problem in?

No response

How can we reproduce this issue?

  1. Go to https://opensource.adobe.com/spectrum-web-components/components/action-group/#selected
  2. Inspect the example in the debugger
  3. Remove the selected attribute from the sp-action-group by editing the html in the debugger
  4. You'll see a console error.

Sample code that illustrates the problem

No response

Logs taken while reproducing problem

No response

adixon-adobe avatar Jul 12 '23 18:07 adixon-adobe

After taking a quick look at the code it made more sense to write this as a one-off issue than a general issue, since there's an actual difference in the value when the component doesn't have a selected attribute, versus when one is added and removed.

The other cases I was thinking of in our discussion at the office hours meeting are where component actually adds the attribute to the DOM. In this case, the DOM looks the same, but the internal values are actually different.

adixon-adobe avatar Jul 12 '23 18:07 adixon-adobe