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

fix(action-group): fixes action group click event which was not selecting action button when they are child elements of action group #3292

Merged
merged 6 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/action-button/src/action-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ governing permissions and limitations under the License.
#label {
flex-grow: var(--spectrum-actionbutton-label-flex-grow);
text-align: var(--spectrum-actionbutton-label-text-align);
pointer-events: none !important;
}

:host([size='xs']) {
Expand Down
43 changes: 43 additions & 0 deletions packages/action-group/test/action-group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,49 @@ describe('ActionGroup', () => {
expect(secondButton.selected, 'second button selected').to.be.true;
});

it('Clicking button event should bubble up from inner label to outer button element', async () => {
const el = await fixture<ActionGroup>(
html`
<sp-action-group
label="Selects Multiple Group"
selects="multiple"
.selected=${['first', 'second']}
>
<sp-action-button class="first" value="first">
First
</sp-action-button>
<sp-action-button class="second" value="second">
Second
</sp-action-button>
</sp-action-group>
`
);

await elementUpdated(el);
expect(el.selected.length).to.equal(2);

const firstButtonEl = el.querySelector('.first') as ActionButton;
const firstSpanEl = firstButtonEl.shadowRoot.querySelector(
'#label'
) as HTMLSpanElement;
const secondButtonEl = el.querySelector('.second') as ActionButton;

expect(firstButtonEl.selected, 'first button selected').to.be.true;
expect(secondButtonEl.selected, 'second button selected').to.be.true;

firstSpanEl.click(); // clicking inner span bubbles up and fires outer button click
await elementUpdated(el);

expect(firstButtonEl.selected, 'first button selected').to.be.false;
expect(secondButtonEl.selected, 'second button selected').to.be.true;

firstButtonEl.click(); // clicking outer action-button element fires own click event
await elementUpdated(el);

expect(firstButtonEl.selected, 'first button selected').to.be.true;
expect(secondButtonEl.selected, 'second button selected').to.be.true;
});

it('only selects user-passed buttons if present in action-group while [selects="multiple"]', async () => {
const el = await multipleSelectedActionGroup(['second', 'fourth']);

Expand Down