-
Notifications
You must be signed in to change notification settings - Fork 273
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
fix: by monitoring the route, display the corresponding directory content in the left menu #2278
Conversation
…tent in the left menu
WalkthroughThe changes in this pull request involve modifications to the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
[e2e-test-warn] The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug". Please make sure you've read our contributing guide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
examples/sites/src/views/layout/layout.vue (1)
132-141
: LGTM with a suggestion: Watching route changes.The implementation of the
watch
function effectively updates the left menu based on route changes, which aligns with the PR objective. However, consider the following suggestion:Consider adding a check to ensure that the derived key (
list[list.length - 1]
) corresponds to a valid menu item before updatingexpandKeys
andtreeMenuRef
. This could prevent potential errors if the last segment of the path doesn't match any menu item.Here's a possible implementation:
watch( () => route.path, (currentVal) => { const list = currentVal.split('/') const key = list[list.length - 1] - state.expandKeys = [key] - state.treeMenuRef.setCurrentKey(key) + if (state.menuOptions.some(item => item.key === key)) { + state.expandKeys = [key] + state.treeMenuRef.setCurrentKey(key) + } } )This change ensures that the menu is only updated when the key corresponds to a valid menu item.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- examples/sites/src/views/layout/layout.vue (3 hunks)
🧰 Additional context used
🔇 Additional comments (3)
examples/sites/src/views/layout/layout.vue (3)
59-59
: LGTM: Importing thewatch
function.The addition of
watch
to the import statement is correct and necessary for the new functionality implemented in this component.
99-99
: LGTM: Addingroute
constant.The addition of the
route
constant usinguseRoute()
is correct. This will allow the component to access and react to changes in the current route.
Line range hint
1-441
: Overall assessment: PR objectives achieved.The changes in this file successfully implement the functionality to display the corresponding directory content in the left menu based on the current route. The code is well-structured, follows Vue.js best practices, and the changes are minimal and focused.
To ensure that the changes don't introduce any regressions, please consider adding tests for this new functionality. Additionally, update the component's documentation to reflect these changes.
…tent in the left menu
PR
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?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Bug Fixes