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
fix(action-group): fixes action group click event which was not selecting action button when they are child elements of action group #3292
Conversation
I wonder if there is a CSS only solution to this? Possibly:
🤔... |
Should I use it here and test it out? |
That file is mechanically generated, so you'll need to include it here, to test. 🤞🏼 |
I did more research and found why above CSS won't work I think. The |
I see. My intent was for this CSS rule to be added to the Action Button, not the Group. The hope there being that no matter what was slotted into the Action Button the host would receive all events. If that doesn’t work, we can move forward with you approach in JS. |
CSS fix on Action Button is working fine. Thanks for the hint. |
Motivation and context
I’m trying to use
sp-action-group
component withsp-action-button
as child components. When I try to select/click one of thesp-action-button
, it calls handleClick event. Here,event.target
is alwaysspan
instead of parentsp-action-button
. And, because of thattarget.value
is alwaysundefined
and returns and does nothing.Technical detail: Retargeting is not occuring because the event occurs on a slotted element inside action button, that physically lives in the light DOM. And because of that event.target is always
span
instead ofsp-action-button
. To fix that, we used event.composedPath() and compares if any html element in path isaction button
that is part ofthis.buttons
.Related issue(s)
#3048
Slack discussion
How has this been tested?
ccx-commenting uses filter popover to filter comments where we have multiple action groups(as various filters) with action buttons as child elements. When we tried to use SWC (instead of RS2), clicking various filters (clicking action button) was not selecting action button(filter not being applied). I tested fix directly in commenting component.
Types of changes
Checklist
Best practices
This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against
main
.