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

Convert slotchange event to MutationObserver #205 #206

Merged
merged 5 commits into from
Nov 20, 2024

Conversation

rmenner
Copy link
Contributor

@rmenner rmenner commented Nov 15, 2024

Alaska Airlines Pull Request

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

Enhancements:

  • Replace slotchange event with MutationObserver for better slot change handling in AuroCombobox.

@rmenner rmenner self-assigned this Nov 15, 2024
@rmenner rmenner requested a review from a team as a code owner November 15, 2024 16:54
Copy link

sourcery-ai bot commented Nov 15, 2024

Reviewer's Guide by Sourcery

This PR replaces the slotchange event with a MutationObserver to handle updates to child nodes in the slot. The implementation adds a new MutationObserver instance that watches for changes in the default slot's child nodes and their subtree, ensuring proper cleanup by disconnecting the observer when the component is destroyed.

Sequence diagram for MutationObserver replacing slotchange event

sequenceDiagram
    participant User
    participant AuroCombobox
    participant MutationObserver

    User->>AuroCombobox: Load component
    AuroCombobox->>MutationObserver: Initialize observer
    MutationObserver->>AuroCombobox: Observe slot changes
    AuroCombobox->>AuroCombobox: handleSlotChange()
    AuroCombobox->>MutationObserver: Disconnect observer on destroy
Loading

Updated class diagram for AuroCombobox

classDiagram
    class AuroCombobox {
        +AuroLibraryRuntimeUtils runtimeUtils
        +MutationObserver observer
        +configureDropdown()
        +handleSlotChange()
        +observeSlotChanges()
        +disconnectedCallback()
        +render()
    }
    note for AuroCombobox "MutationObserver replaces slotchange event handling"
Loading

File-Level Changes

Change Details Files
Implemented MutationObserver for slot changes
  • Added a new MutationObserver instance in the constructor
  • Created observeSlotChanges method to set up the observer
  • Added observer cleanup in disconnectedCallback
  • Removed slotchange event binding from the slot element
  • Updated handleSlotChange method to include showBib call
src/auro-combobox.js
Updated dependency versions
  • Upgraded auro-dropdown to version 3.2.0
  • Upgraded auro-input to version 4.2.0
  • Upgraded auro-menu to version 4.1.5
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

@rmenner rmenner linked an issue Nov 15, 2024 that may be closed by this pull request
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @rmenner - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider disconnecting the MutationObserver in disconnectedCallback to prevent potential memory leaks
  • The showBib() function call needs documentation to explain its purpose and why it's needed in handleSlotChange
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

src/auro-combobox.js Outdated Show resolved Hide resolved
src/auro-combobox.js Outdated Show resolved Hide resolved
@rmenner
Copy link
Contributor Author

rmenner commented Nov 15, 2024

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @rmenner - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

src/auro-combobox.js Outdated Show resolved Hide resolved
src/auro-combobox.js Outdated Show resolved Hide resolved
src/auro-combobox.js Outdated Show resolved Hide resolved
src/auro-combobox.js Show resolved Hide resolved
src/auro-combobox.js Show resolved Hide resolved
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ rmenner
❌ Jason Baker


Jason Baker seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@rmenner rmenner merged commit 5b09bab into main Nov 20, 2024
5 of 6 checks passed
@rmenner rmenner deleted the rmenner/mutation-observer-slot-change branch November 20, 2024 01:06
@blackfalcon
Copy link
Member

🎉 This PR is included in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@blackfalcon blackfalcon added the released Completed work has been released label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Completed work has been released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Event slotchange not triggering for react vdom
4 participants