spectrum-web-components
spectrum-web-components copied to clipboard
[Bug]: Removing `selected` attribute from sp-action-group leads to console error
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?
- Go to https://opensource.adobe.com/spectrum-web-components/components/action-group/#selected
- Inspect the example in the debugger
- Remove the
selected
attribute from the sp-action-group by editing the html in the debugger - You'll see a console error.
Sample code that illustrates the problem
No response
Logs taken while reproducing problem
No response
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.