vmware-clarity / core

Clarity is a scalable, accessible, customizable, open-source design system built with web components. Works with any JavaScript framework, created for enterprises, and designed to be inclusive.
https://clarity.design
MIT License
163 stars 42 forks source link

fix(navigation): sync state with newly added nav items #156

Closed ashleyryan closed 2 years ago

ashleyryan commented 2 years ago

fixes #155 #82

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

What is the current behavior?

Previously, expanded state was only shared with nav items on the initial render, or when the parent navigation component had updates. Asynchronously added nav items were treated as collapses, instead of having their parent state synced

Issue Number: #155 #82

What is the new behavior?

the slotchange event was added to the slot to detect when new items are added

Does this PR introduce a breaking change?

Other information

github-actions[bot] commented 2 years ago

πŸ‘‹ @ashleyryan,

Thank you,

πŸ€– Clarity Release Bot

ashleyryan commented 2 years ago

If you find time some parts of the code of the navigation could be moved to controllers.

Yeah I had the same thought when I was looking at the code. Might be a good exercise to get some more lit experience.

ashleyryan commented 2 years ago

Commit message fixed. The slotChange event notifies you if content has been added/removed from the slot. So instead of only syncing the props, and setting tabIndex on firstUpdate or when the component updates, it will do it everytime a new nav item is added (or removed, which is unnecessary, but not really a problem)

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 6.1.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 2 years ago

Hi there πŸ‘‹, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed PRs after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.