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

Handle nested clickable trigger elements #154

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jordanjones243
Copy link
Contributor

@jordanjones243 jordanjones243 commented Jan 21, 2025

Alaska Airlines Pull Request

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Resolves: #153

Summary:

Please summarize the scope of the changes you have submitted, what the intent of the work is and anything that describes the before/after state of the project.

Type of change:

Please delete options that are not relevant.

  • New capability
  • Revision of an existing capability
  • Infrastructure change (automation, etc.)
  • Other (please elaborate)

Checklist:

  • My update follows the CONTRIBUTING guidelines of this project
  • I have performed a self-review of my own update

By submitting this Pull Request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Pull Requests will be evaluated by their quality of update and whether it is consistent with the goals and values of this project. Any submission is to be considered a conversation between the submitter and the maintainers of this project and may require changes to your submission.

Thank you for your submission!

-- Auro Design System Team

Summary by Sourcery

New Features:

  • Enable clickable elements, such as buttons, within accordion triggers.

@jordanjones243 jordanjones243 self-assigned this Jan 21, 2025
Copy link

sourcery-ai bot commented Jan 21, 2025

Reviewer's Guide by Sourcery

This pull request addresses an issue where nested clickable elements within an accordion trigger were not handled correctly. The fix ensures that clicks on these nested elements do not interfere with the accordion's toggle behavior. Additionally, the auro-accordion-button component was refactored to extend LitElement instead of AuroButton.

Sequence diagram for nested button click handling

sequenceDiagram
    actor User
    participant NB as Nested Button
    participant AB as Accordion Button
    participant AC as Accordion Component

    User->>NB: clicks nested button
    NB->>NB: stopImmediatePropagation()
    NB->>NB: stopPropagation()
    NB-->>User: handle button click
    Note over NB,AB: Event propagation stopped
    Note right of AB: Accordion remains unchanged

    User->>AB: clicks accordion button
    AB->>AC: toggle()
    AC->>AC: update expanded state
    AC-->>User: show/hide content
Loading

Class diagram showing accordion button component changes

classDiagram
    class LitElement
    class AuroAccordionButton {
        +static styles
        +static properties
        +static register(name)
        +render()
    }
    note for AuroAccordionButton "Changed parent class from AuroButton to LitElement"

    LitElement <|-- AuroAccordionButton

    class AuroAccordion {
        -expanded: boolean
        -accordionButton: Element
        +firstUpdated()
        +toggle()
        +render()
    }
    note for AuroAccordion "Added event listener in firstUpdated"
Loading

File-Level Changes

Change Details Files
Refactor auro-accordion-button to extend LitElement instead of AuroButton.
  • Changed the base class of AuroAccordionButton from AuroButton to LitElement.
  • Removed the import of styleCssAuroButton.
  • Updated the render method to use Lit's html template literal and ifDefined directive.
  • Removed the call to super() in the constructor.
  • Removed the static get properties() method.
  • Updated the button element to use the part attribute instead of the class attribute.
src/auro-accordion-button.js
Add nested button example to the documentation.
  • Added a new example demonstrating a nested button within an accordion trigger.
  • Included the necessary HTML and JavaScript code for the example.
  • Updated the documentation to include the new example.
demo/api.md
docs/partials/api.md
apiExamples/nestedButton.html
apiExamples/nestedButton.js
Modify the accordion to handle clicks on nested elements within the trigger.
  • Added an event listener to the auro-accordion-button to toggle the accordion when clicked.
  • Removed the click handler from the trigger element.
src/auro-accordion.js
Update styling for auro-accordion-button.
  • Updated the styling to target the button element directly instead of the .auro-button class.
  • Removed the pointer-events: none from the button element.
  • Removed the after pseudo element styling.
src/style-button.scss
Update package dependencies.
  • Updated the version of @aurodesignsystem/auro-button.
  • Updated the version of @aurodesignsystem/auro-icon.
  • Updated the version of @aurodesignsystem/auro-library.
  • Updated the version of chalk.
  • Updated the version of @commitlint/cli.
  • Updated the version of @commitlint/config-conventional.
  • Updated the version of @rollup/plugin-node-resolve.
  • Updated the version of concurrently.
  • Updated the version of core-js.
  • Updated the version of eslint.
  • Updated the version of eslint-plugin-jsdoc.
  • Updated the version of husky.
  • Updated the version of nodemon.
  • Updated the version of postcss.
  • Updated the version of rollup.
  • Updated the version of sass.
  • Updated the version of semantic-release.
  • Updated the version of stylelint.
  • Updated the version of stylelint-config-standard.
  • Updated the version of stylelint-config-standard-scss.
  • Updated the version of stylelint-scss.
  • Updated the version of typescript.
package.json
package-lock.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

github-actions bot commented Jan 21, 2025

Surge demo deployment failed! 😭

<auro-accordion id="nestedButtonExample">
<span slot="trigger">
Click the button for a test
<button id="nestedButton">Alaska Airlines</button>
Copy link
Member

Choose a reason for hiding this comment

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

Our example needs to be an auro-button rather than an HTML5 button.

button.addEventListener('click', (event) => {
event.stopImmediatePropagation();
event.stopPropagation();
console.log('Button clicked');
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
console.log('Button clicked');
console.log('The button in the accordion trigger was clicked. Accordion should not have expanded or collapsed.');

@@ -142,6 +148,7 @@ export class AuroAccordion extends LitElement {
* Toggles the visibility of the accordion content.
*/
toggle() {
console.log('button clicked, toggling.......')
Copy link
Member

Choose a reason for hiding this comment

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

I think we can ditch this console log since it's obvious on the screen that the UI changes.

Comment on lines +27 to +45
// &:after {
// border-color: transparent; // not supported by tokens - this should never have a color regardless of the theme
// }
}

// .auro-button {
// all: unset;
// width: 100%;
// padding: var(--ds-size-200, $ds-size-200) 0;

// cursor: pointer;

// pointer-events: none;

// &:after {
// border-color: transparent; // not supported by tokens - this should never have a color regardless of the theme
// }
// }

Copy link
Member

Choose a reason for hiding this comment

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

Get rid of the commented out code.

@@ -13,20 +13,36 @@
:host {
border: unset;

.auro-button {
button {
font: inherit;
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need this font rule?

@jordanjones243 jordanjones243 force-pushed the jjones/clickableTriggerItems/#152 branch from 84b7fc1 to 9e2e342 Compare January 21, 2025 21:39
@jordanjones243 jordanjones243 force-pushed the jjones/clickableTriggerItems/#152 branch from bd41328 to ffaf7b4 Compare January 21, 2025 23:32
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.

Refactor accordion to handle clickable elements within the trigger
2 participants