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

feat(action-button): allow change events to bubble and pierce shadowdom #3614

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

nickschaap
Copy link
Contributor

@nickschaap nickschaap commented Sep 1, 2023

Description

Action button change events should bubble and be composed to match behavior with other SWC components which fire change events such as sp-switch and sp-checkbox

Related issue(s)

Motivation and context

How has this been tested?

  • Test case 1
    1. Go here
    2. Do this
  • Test case 2
    1. Go here
    2. Do this

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

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.

@nickschaap nickschaap linked an issue Sep 1, 2023 that may be closed by this pull request
1 task
@nickschaap nickschaap changed the title fix(action-button): allow change events to bubble and pierce shadowdom feat(action-button): allow change events to bubble and pierce shadowdom Sep 1, 2023
@nickschaap nickschaap requested a review from Westbrook September 1, 2023 21:45
@github-actions
Copy link

github-actions bot commented Sep 1, 2023

Tachometer results

Chrome

action-bar permalink

Version Bytes Avg Time vs remote vs branch
npm latest 477 kB 114.04ms - 115.61ms - unsure 🔍
-1% - +1%
-1.48ms - +0.93ms
branch 472 kB 114.18ms - 116.02ms unsure 🔍
-1% - +1%
-0.93ms - +1.48ms
-

action-button permalink

Version Bytes Avg Time vs remote vs branch
npm latest 507 kB 192.52ms - 195.69ms - unsure 🔍
-1% - +1%
-2.70ms - +1.71ms
branch 502 kB 193.08ms - 196.13ms unsure 🔍
-1% - +1%
-1.71ms - +2.70ms
-

action-group permalink

Version Bytes Avg Time vs remote vs branch
npm latest 528 kB 125.37ms - 131.14ms - unsure 🔍
-1% - +4%
-1.26ms - +4.74ms
branch 523 kB 125.70ms - 127.32ms unsure 🔍
-4% - +1%
-4.74ms - +1.26ms
-

action-menu permalink

Version Bytes Avg Time vs remote vs branch
npm latest 630 kB 223.36ms - 227.00ms - unsure 🔍
-1% - +1%
-3.15ms - +2.19ms
branch 625 kB 223.71ms - 227.61ms unsure 🔍
-1% - +1%
-2.19ms - +3.15ms
-

menu permalink

Version Bytes Avg Time vs remote vs branch
npm latest 452 kB 328.22ms - 332.35ms - unsure 🔍
-1% - +1%
-1.92ms - +3.12ms
branch 447 kB 328.24ms - 331.13ms unsure 🔍
-1% - +1%
-3.12ms - +1.92ms
-

number-field permalink

Version Bytes Avg Time vs remote vs branch
npm latest 623 kB 195.85ms - 198.01ms - unsure 🔍
-1% - +1%
-1.35ms - +1.90ms
branch 618 kB 195.45ms - 197.87ms unsure 🔍
-1% - +1%
-1.90ms - +1.35ms
-

overlay permalink

Version Bytes Avg Time vs remote vs branch
npm latest 493 kB 95.08ms - 97.02ms - unsure 🔍
-1% - +2%
-1.12ms - +1.57ms
branch 473 kB 94.89ms - 96.76ms unsure 🔍
-2% - +1%
-1.57ms - +1.12ms
-

picker permalink

Version Bytes Avg Time vs remote vs branch
npm latest 496 kB 767.08ms - 786.24ms - unsure 🔍
-2% - +2%
-15.82ms - +12.16ms
branch 491 kB 768.29ms - 788.68ms unsure 🔍
-2% - +2%
-12.16ms - +15.82ms
-

popover permalink

Version Bytes Avg Time vs remote vs branch
npm latest 374 kB 36.67ms - 37.26ms - unsure 🔍
-2% - +0%
-0.76ms - +0.17ms
branch 369 kB 36.90ms - 37.62ms unsure 🔍
-0% - +2%
-0.17ms - +0.76ms
-

slider permalink

Version Bytes Avg Time vs remote vs branch
npm latest 462 kB 158.23ms - 160.61ms - unsure 🔍
-2% - +0%
-2.92ms - +0.11ms
branch 457 kB 159.88ms - 161.76ms unsure 🔍
-0% - +2%
-0.11ms - +2.92ms
-

split-button permalink

Version Bytes Avg Time vs remote vs branch
npm latest 701 kB 1887.03ms - 1890.23ms - unsure 🔍
-0% - +0%
-3.23ms - +1.65ms
branch 695 kB 1887.58ms - 1891.27ms unsure 🔍
-0% - +0%
-1.65ms - +3.23ms
-

tooltip permalink

Version Bytes Avg Time vs remote vs branch
npm latest 546 kB 82.07ms - 83.70ms - unsure 🔍
-0% - +2%
-0.40ms - +1.58ms
branch 539 kB 81.72ms - 82.87ms unsure 🔍
-2% - +0%
-1.58ms - +0.40ms
-
Firefox

action-bar permalink

Version Bytes Avg Time vs remote vs branch
npm latest 477 kB 319.14ms - 348.30ms - unsure 🔍
-5% - +6%
-18.10ms - +18.54ms
branch 472 kB 322.40ms - 344.60ms unsure 🔍
-6% - +5%
-18.54ms - +18.10ms
-

action-button permalink

Version Bytes Avg Time vs remote vs branch
npm latest 507 kB 458.90ms - 486.70ms - unsure 🔍
-5% - +3%
-24.81ms - +16.65ms
branch 502 kB 461.51ms - 492.25ms unsure 🔍
-4% - +5%
-16.65ms - +24.81ms
-

action-group permalink

Version Bytes Avg Time vs remote vs branch
npm latest 528 kB 293.38ms - 311.02ms - unsure 🔍
-9% - +1%
-29.77ms - +3.25ms
branch 523 kB 301.51ms - 329.41ms unsure 🔍
-1% - +10%
-3.25ms - +29.77ms
-

action-menu permalink

Version Bytes Avg Time vs remote vs branch
npm latest 630 kB 468.75ms - 505.65ms - unsure 🔍
-4% - +7%
-18.61ms - +32.37ms
branch 625 kB 462.73ms - 497.91ms unsure 🔍
-7% - +4%
-32.37ms - +18.61ms
-

menu permalink

Version Bytes Avg Time vs remote vs branch
npm latest 452 kB 674.44ms - 717.44ms - unsure 🔍
-4% - +5%
-26.28ms - +31.64ms
branch 447 kB 673.87ms - 712.65ms unsure 🔍
-5% - +4%
-31.64ms - +26.28ms
-

number-field permalink

Version Bytes Avg Time vs remote vs branch
npm latest 623 kB 443.59ms - 477.61ms - unsure 🔍
-5% - +5%
-22.10ms - +21.26ms
branch 618 kB 447.58ms - 474.46ms unsure 🔍
-5% - +5%
-21.26ms - +22.10ms
-

overlay permalink

Version Bytes Avg Time vs remote vs branch
npm latest 570 kB 210.56ms - 228.00ms - unsure 🔍
-4% - +8%
-7.44ms - +16.52ms
branch 565 kB 206.52ms - 222.96ms unsure 🔍
-7% - +3%
-16.52ms - +7.44ms
-

picker permalink

Version Bytes Avg Time vs remote vs branch
npm latest 496 kB 1215.83ms - 1264.61ms - unsure 🔍
-2% - +3%
-28.53ms - +34.41ms
branch 491 kB 1217.40ms - 1257.16ms unsure 🔍
-3% - +2%
-34.41ms - +28.53ms
-

popover permalink

Version Bytes Avg Time vs remote vs branch
npm latest 374 kB 124.50ms - 141.18ms - unsure 🔍
-6% - +12%
-7.70ms - +15.34ms
branch 369 kB 121.07ms - 136.97ms unsure 🔍
-11% - +6%
-15.34ms - +7.70ms
-

slider permalink

Version Bytes Avg Time vs remote vs branch
npm latest 462 kB 364.30ms - 381.86ms - unsure 🔍
-9% - +0%
-35.63ms - +2.11ms
branch 457 kB 373.14ms - 406.54ms unsure 🔍
-1% - +10%
-2.11ms - +35.63ms
-

split-button permalink

Version Bytes Avg Time vs remote vs branch
npm latest 701 kB 1620.05ms - 1629.39ms - unsure 🔍
-1% - +0%
-14.22ms - +2.98ms
branch 695 kB 1623.12ms - 1637.56ms unsure 🔍
-0% - +1%
-2.98ms - +14.22ms
-

tooltip permalink

Version Bytes Avg Time vs remote vs branch
npm latest 635 kB 171.22ms - 185.22ms - unsure 🔍
-5% - +5%
-8.60ms - +9.48ms
branch 629 kB 172.06ms - 183.50ms unsure 🔍
-5% - +5%
-9.48ms - +8.60ms
-

@@ -363,6 +363,7 @@ export class ActionGroup extends SizedMixin(SpectrumElement, {

private manageChildren(changes?: PropertyValues): void {
this.buttons.forEach((button) => {
button.toggles = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could cause an issue when a consumer leverages an Action Group without selects but Action Buttons with toggles in order to manage the selection of elements in the group via some custom algorithm.

I think with the change to Action Button, that we want to move away from listened on click and to listening on change and then event.stopPropagation()ing the child event. Much like we see in Radio Group.

Copy link
Contributor Author

@nickschaap nickschaap Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Westbrook Does that mean we want to dispatch a change event for all clicks on action buttons? Currently change events are only dispatched for action buttons that toggle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this is a bit more complex than Radio Group.

The context is that if the Action Group should dispatch change events (selects === 'single' | 'multiple') we shouldn't prevent child Action Buttons from dispatching change events (button.toggles = false;). In that context we should listen for those change events and event.stopPropagation() on them. We likely also want to event.preventDefault() them, as the Action Button is a controller component of the Action Group in that case and does not get to determine its own state.

Does that make next steps here clear enough?

Copy link
Contributor

@Westbrook Westbrook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickschaap, made a couple of changes and think this is OK to land. Can you confirm whether you think this would cover your original use case before we merge?

@nickschaap
Copy link
Contributor Author

@Westbrook LGTM thanks!

@Westbrook Westbrook merged commit 3f76e04 into main Oct 3, 2023
8 checks passed
@Westbrook Westbrook deleted the change-bubble branch October 3, 2023 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat]: Allow sp-action-button change events to bubble and be composed
2 participants