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(menu): add multi-select & component refactor #133

Merged
merged 9 commits into from
Jan 17, 2025
Merged

Conversation

chrisfalaska
Copy link
Contributor

@chrisfalaska chrisfalaska commented Dec 19, 2024

Alaska Airlines Pull Request

Multi-select was originally added to auro-menu as a pending PR in AlaskaAirlines/auro-menu#199.

This feature was never merged or integrated but was selected for adoption into @auro-formkit/auro-menu. This PR incorporates that adoption into the formkit monorepo.

Testing

Screenshot 2024-12-19 at 1 41 30 PM

Screenshot 2024-12-19 at 1 41 53 PM

menu-muli-select.mp4

Summary by Sourcery

Add multi-select functionality to the menu component and implement loading states for combobox, menu, and select components. Update documentation and fix multiple bugs.

New Features:

  • Add multi-select support to auro-menu.

Tests:

  • Add tests for the multi-select functionality.

Summary by Sourcery

Add multi-select functionality to the auro-menu component.

New Features:

  • Allow multiple options to be selected in auro-menu.

Tests:

  • Add tests for multi-select functionality, including selecting and deselecting multiple options, handling disabled options, and managing aria-selected states.
test/auro-menu.test.js:
@auro-formkit/auro-menu:test: 
@auro-formkit/auro-menu:test:  🚧 Browser logs:
@auro-formkit/auro-menu:test:       Lit is in dev mode. Not recommended for production! See https://lit.dev/msg/dev-mode for more information.
@auro-formkit/auro-menu:test: 
@auro-formkit/auro-menu:test: Chrome: |██████████████████████████████| 1/1 test files | 28 passed, 0 failed
@auro-formkit/auro-menu:test: 
@auro-formkit/auro-menu:test: Code coverage: 96.8 %
@auro-formkit/auro-menu:test: View full coverage report at coverage/lcov-report/index.html
@auro-formkit/auro-menu:test: 
@auro-formkit/auro-menu:test: Finished running tests in 2.3s, all tests passed! 🎉
@auro-formkit/auro-menu:test: 

Summary by Sourcery

Add multi-select functionality to the auro-menu component.

New Features:

  • Allow multiple options to be selected in auro-menu.

Tests:

  • Add tests for multi-select functionality, including selecting and deselecting multiple options, handling disabled options, and managing aria-selected states.

@chrisfalaska chrisfalaska self-assigned this Dec 19, 2024
Copy link

sourcery-ai bot commented Dec 19, 2024

Reviewer's Guide by Sourcery

This pull request introduces multi-select functionality to the auro-menu component and refactors the component to improve its structure and functionality. It also includes updates to tests, documentation, and bug fixes.

Class diagram showing the updated AuroMenu component structure

classDiagram
    class AuroMenu {
        +Boolean multiSelect
        +Array~string~ value
        +Array~HTMLElement~ optionSelected
        +String matchWord
        +Boolean noCheckmark
        +Boolean loading
        +HTMLElement optionActive
        +reset()
        -handleSelectState(option)
        -handleDeselectState(option)
        -clearSelection()
        -navigateOptions(direction)
        -isOptionSelected(option)
        -notifySelectionChange()
    }
    class AuroSelect {
        +Boolean multiSelect
        +Array~string~ value
        +Array~HTMLElement~ optionSelected
        +updateDisplayedValue()
    }
    class AuroCombobox {
        +Array~string~ value
        +Array~HTMLElement~ optionSelected
        -handleInputValueChange()
    }
    AuroMenu <-- AuroSelect: uses
    AuroMenu <-- AuroCombobox: uses
Loading

State diagram for menu option selection states

stateDiagram-v2
    [*] --> Unselected
    Unselected --> SingleSelected: Click (single-select)
    Unselected --> MultiSelected: Click (multi-select)
    SingleSelected --> Unselected: Click/Reset
    MultiSelected --> PartialSelected: Deselect some
    PartialSelected --> MultiSelected: Select more
    PartialSelected --> Unselected: Deselect all/Reset
    MultiSelected --> Unselected: Deselect all/Reset
Loading

File-Level Changes

Change Details Files
Added multi-select functionality
  • Added multiSelect property to auro-menu component
  • Updated keyboard and mouse event handling to support selecting and deselecting multiple options
  • Added tests for multi-select functionality, including selecting, deselecting, disabled options, and aria-selected states
  • Updated value property to handle arrays of selected values in multi-select mode
components/menu/test/auro-menu.test.js
components/menu/src/auro-menu.js
Refactored component structure and logic
  • Improved keyboard navigation logic
  • Simplified selection and deselection logic
  • Improved handling of custom events
  • Added arrayConverter utility function to handle array values
  • Updated value and optionSelected properties to use arrays for both single and multi-select modes
components/menu/src/auro-menu.js
Updated tests and documentation
  • Added tests for keyboard navigation, custom events, and value handling
  • Updated documentation to reflect the new multi-select functionality and component API changes
  • Added examples for multi-select usage
components/menu/test/auro-menu.test.js
components/menu/demo/api.md
components/menu/docs/api.md
components/menu/docs/partials/api.md
Fixed multiple bugs
  • Fixed issue with incorrect value handling
  • Fixed issue with keyboard navigation skipping disabled options
  • Fixed issue with incorrect aria-selected states
components/menu/src/auro-menu.js
Updated component integration in combobox and select components
  • Updated auro-combobox and auro-select to handle the new multiSelect property and array values
  • Updated tests and documentation for auro-combobox and auro-select
  • Added support for multi-select in auro-select
components/combobox/src/auro-combobox.js
components/select/src/auro-select.js
components/combobox/demo/api.md
components/combobox/README.md
components/combobox/apiExamples/value.js
components/combobox/apiExamples/dynamicMenu.js
components/combobox/apiExamples/programmaticValue.html
components/combobox/apiExamples/value.html
components/combobox/docs/api.md
components/select/demo/api.md
components/select/docs/api.md
components/select/docs/partials/api.md
components/select/src/styles/style.scss
components/select/README.md
components/select/apiExamples/inDialog.html
components/select/apiExamples/resetState.html
components/select/apiExamples/value.html
components/select/apiExamples/value.js
components/select/apiExamples/multiselect.html
components/menu/src/index.js
components/menu/apiExamples/reset.js
components/menu/README.md

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

@CLAassistant
Copy link

CLAassistant commented Dec 19, 2024

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.

✅ jordanjones243
❌ chrisfalaska


chrisfalaska 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.

@chrisfalaska chrisfalaska changed the base branch from main to beta December 19, 2024 21:46
@chrisfalaska chrisfalaska linked an issue Dec 19, 2024 that may be closed by this pull request
@chrisfalaska chrisfalaska marked this pull request as ready for review December 23, 2024 23:35
@chrisfalaska chrisfalaska requested a review from a team as a code owner December 23, 2024 23:35
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 @chrisfalaska - 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: 4 issues found
  • 🟢 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.

components/menu/test/auro-menu.test.js Outdated Show resolved Hide resolved
components/menu/test/auro-menu.test.js Show resolved Hide resolved
components/menu/test/auro-menu.test.js Show resolved Hide resolved
components/menu/test/auro-menu.test.js Show resolved Hide resolved
components/menu/demo/api.md Outdated Show resolved Hide resolved
components/menu/src/auro-menu.js Outdated Show resolved Hide resolved
components/menu/src/auro-menu.js Outdated Show resolved Hide resolved
@chrisfalaska chrisfalaska marked this pull request as draft December 23, 2024 23:49
@chrisfalaska chrisfalaska marked this pull request as ready for review December 30, 2024 19:02
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 @chrisfalaska - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 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.

Copy link
Member

@jason-capsule42 jason-capsule42 left a comment

Choose a reason for hiding this comment

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

Refactor selection logic based on our conversation so that the value/optionSelected logic is isolated from the UI updates. And make the UI updates responsive to value/optionSelected in the updated() function rather than triggered directly by the selection event.

components/combobox/demo/api.min.js Outdated Show resolved Hide resolved
components/combobox/demo/api.min.js Outdated Show resolved Hide resolved
components/menu/src/auro-menu.js Outdated Show resolved Hide resolved
@chrisfalaska chrisfalaska changed the title feat(menu): add multi-select feat(menu): add multi-select & component refactor Jan 2, 2025
@chrisfalaska
Copy link
Contributor Author

@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 @chrisfalaska - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider moving event handler bindings from constructor to connectedCallback/disconnectedCallback to prevent potential memory leaks during component lifecycle
  • Consider consolidating duplicate event dispatch code into a helper method to improve maintainability and reduce code duplication
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 4 issues found
  • 🟢 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.

components/menu/src/auro-menu.js Outdated Show resolved Hide resolved
components/menu/src/auro-menu.js Show resolved Hide resolved
components/menu/test/auro-menu.test.js Outdated Show resolved Hide resolved
components/menu/test/auro-menu.test.js Show resolved Hide resolved
components/menu/test/auro-menu.test.js Show resolved Hide resolved
components/menu/test/auro-menu.test.js Show resolved Hide resolved
components/menu/demo/api.md Outdated Show resolved Hide resolved
components/menu/docs/api.md Outdated Show resolved Hide resolved
components/menu/docs/partials/api.md Outdated Show resolved Hide resolved
components/menu/docs/api.md Outdated Show resolved Hide resolved
components/menu/docs/api.md Show resolved Hide resolved
components/menu/src/auro-menu.js Outdated Show resolved Hide resolved
components/menu/src/auro-menu.js Outdated Show resolved Hide resolved
components/menu/src/auro-menu.js Outdated Show resolved Hide resolved
components/menu/src/auro-menu.js Outdated Show resolved Hide resolved
components/menu/src/auro-menu.js Outdated Show resolved Hide resolved
@chrisfalaska
Copy link
Contributor Author

@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 @chrisfalaska - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 4 issues found
  • 🟢 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.

components/menu/test/auro-menu.test.js Outdated Show resolved Hide resolved
components/menu/test/auro-menu.test.js Outdated Show resolved Hide resolved
components/menu/test/auro-menu.test.js Outdated Show resolved Hide resolved
components/menu/test/auro-menu.test.js Show resolved Hide resolved
components/menu/src/auro-menu.js Outdated Show resolved Hide resolved
components/menu/src/auro-menu-utils.js Show resolved Hide resolved
Copy link
Contributor

@jordanjones243 jordanjones243 left a comment

Choose a reason for hiding this comment

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

Can there be some cleanup around commits? 72 commits for 10 file changes seems a bit excessive and I see some duplicate commits in there.

@chrisfalaska
Copy link
Contributor Author

chrisfalaska commented Jan 8, 2025

Can there be some cleanup around commits? 72 commits for 10 file changes seems a bit excessive and I see some duplicate commits in there.

I can squash and merge into a single commit. It's one big refactor, I'd argue preserving the commit history is not so important.

EDIT: I squashed some of the duplicate-named commits and reduced the overall number by a few. Thank you for the feedback!

components/combobox/apiExamples/value.js Outdated Show resolved Hide resolved
components/combobox/src/auro-combobox.js Outdated Show resolved Hide resolved
components/combobox/src/auro-combobox.js Outdated Show resolved Hide resolved
components/combobox/src/auro-combobox.js Outdated Show resolved Hide resolved
components/combobox/src/auro-combobox.js Outdated Show resolved Hide resolved
components/combobox/src/auro-combobox.js Outdated Show resolved Hide resolved
components/select/src/auro-select.js Outdated Show resolved Hide resolved
@chrisfalaska chrisfalaska marked this pull request as draft January 16, 2025 20:56
@chrisfalaska chrisfalaska marked this pull request as ready for review January 16, 2025 22:38
@chrisfalaska chrisfalaska requested a review from sun-mota January 16, 2025 22:39
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 @chrisfalaska - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a migration guide or breaking changes section in the documentation to highlight the change from string to array values, as this could impact existing implementations.
Here's what I looked at during the review
  • 🟡 General issues: 9 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟡 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.

components/menu/src/auro-menu.js Show resolved Hide resolved
components/menu/src/auro-menu-utils.js Show resolved Hide resolved
components/menu/test/auro-menu.test.js Show resolved Hide resolved
components/menu/demo/api.md Show resolved Hide resolved
components/menu/docs/api.md Show resolved Hide resolved
components/select/demo/api.md Show resolved Hide resolved
components/select/docs/api.md Show resolved Hide resolved
components/select/docs/api.md Show resolved Hide resolved
components/select/src/auro-select.js Show resolved Hide resolved
components/menu/src/auro-menu-utils.js Outdated Show resolved Hide resolved
components/combobox/src/auro-combobox.js Outdated Show resolved Hide resolved
components/combobox/src/auro-combobox.js Outdated Show resolved Hide resolved
components/select/src/auro-select.js Outdated Show resolved Hide resolved
components/select/src/auro-select.js Outdated Show resolved Hide resolved
components/menu/src/auro-menu.js Show resolved Hide resolved
@chrisfalaska chrisfalaska merged commit 2deb304 into beta Jan 17, 2025
3 of 4 checks passed
@chrisfalaska chrisfalaska deleted the cfriedberg/123 branch January 17, 2025 17:24
@jason-capsule42
Copy link
Member

🎉 This PR is included in version 2.0.0-beta.11 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

auro-menu Add Multiselect & Refactor Component
5 participants