-
Notifications
You must be signed in to change notification settings - Fork 21
Fix Vue 3 deprecation warnings for deep selectors and smoothScroll injection
#92
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
Conversation
…hScroll inject default Replace deprecated >>> and /deep/ combinators with :deep() pseudo-class to fix Vue 3 deprecation warnings, and add default value to smoothScroll inject to prevent warnings during SSR. Changes: - Update MainLayout.vue: .btn-soc-med selectors and smoothScroll inject default - Update IndexPage.vue: .btn-contribute selectors This ensures the development server starts without errors and eliminates deprecation warnings in the console.
Complete the fix by adding null default value to smoothScroll inject to prevent warnings during SSR when the injection is not available.
…jectsPage Add null default value to smoothScroll inject and add null checks before using it to prevent warnings during SSR when the injection is not available. This completes the fix for all pages that use smoothScroll injection.
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
WalkthroughDependency injection patterns for Changes
Sequence DiagramsequenceDiagram
participant Setup as Setup Phase
participant Provider as Injection Provider
participant Component as Component
rect rgb(220, 240, 255)
Note over Setup,Component: Before: Assume smoothScroll exists
Setup->>Provider: inject('smoothScroll')
alt Provided
Provider-->>Component: smoothScroll function
else Not Provided
Provider-->>Component: undefined (runtime error risk)
end
end
rect rgb(240, 255, 240)
Note over Setup,Component: After: Explicit null default + Guard
Setup->>Provider: inject('smoothScroll', null)
Provider-->>Component: smoothScroll function or null
Component->>Component: if (smoothScroll) { ... }
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Comment |
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/pages/IndexPage.vue (1)
243-255: Add null-check guard to prevent runtime error.The
smoothScrollinjection now defaults tonull, but this function calls it without checking. This will cause a runtime error during SSR or when the plugin isn't provided.Apply this diff to add the guard (consistent with ProjectsPage.vue and TeamPage.vue):
function onGoToPanel (card) { const panelId = card.panelId; if (card.panelId) { - smoothScroll({ - scrollTo: document.getElementById(panelId), - updateHistory: false, - }); + if (smoothScroll) { + smoothScroll({ + scrollTo: document.getElementById(panelId), + updateHistory: false, + }); + } } if (card.link) { window.open(card.link, '_blank').focus(); } }src/layouts/MainLayout.vue (2)
180-185: Add null-check guard to prevent runtime error.The
smoothScrollinjection now defaults tonull, but this function calls it without checking. This will cause a runtime error during SSR or when the plugin isn't provided.Apply this diff to add the guard:
function onScrollToTop () { - smoothScroll({ - scrollTo: document.getElementById('top'), - updateHistory: false, - }); + if (smoothScroll) { + smoothScroll({ + scrollTo: document.getElementById('top'), + updateHistory: false, + }); + } }
187-198: Add null-check guard to prevent runtime error.The
smoothScrollinjection now defaults tonull, but this function calls it without checking (lines 191-194). This will cause a runtime error during SSR or when the plugin isn't provided.Apply this diff to add the guard:
function onGoToPanel (card) { const panelId = card.panelId; drawerLeft.value = false; if (card.panelId) { - smoothScroll({ - scrollTo: document.getElementById(panelId), - updateHistory: false, - }); + if (smoothScroll) { + smoothScroll({ + scrollTo: document.getElementById(panelId), + updateHistory: false, + }); + } } if (card.route) router.push(card.route); if (card.link) window.open(card.link, '_blank').focus(); }
🧹 Nitpick comments (2)
src/pages/ProjectsPage.vue (1)
56-70: LGTM! Proper null-check guard added.The guard correctly prevents calling
smoothScrollwhen it's null during SSR.Note: The
onGoToPanelfunction doesn't appear to be invoked anywhere in the template. If it's genuinely unused, consider removing it to reduce code complexity.src/pages/TeamPage.vue (1)
153-167: LGTM! Proper null-check guard added.The guard correctly prevents calling
smoothScrollwhen it's null during SSR.Note: The
onGoToPanelfunction doesn't appear to be invoked anywhere in the template. If it's genuinely unused, consider removing it to reduce code complexity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/layouts/MainLayout.vue(2 hunks)src/pages/IndexPage.vue(2 hunks)src/pages/ProjectsPage.vue(1 hunks)src/pages/TeamPage.vue(2 hunks)
🔇 Additional comments (6)
src/pages/ProjectsPage.vue (1)
52-52: LGTM! Proper default value for injection.The explicit
nulldefault prevents SSR warnings when thesmoothScrollprovider is absent.src/pages/TeamPage.vue (1)
122-122: LGTM! Proper default value for injection.The explicit
nulldefault prevents SSR warnings when thesmoothScrollprovider is absent.src/pages/IndexPage.vue (2)
239-239: LGTM! Proper default value for injection.The explicit
nulldefault prevents SSR warnings when thesmoothScrollprovider is absent.
290-296: LGTM! Deprecated deep selector modernized.The change from
>>>to:deep()correctly addresses Vue 3 deprecation warnings.src/layouts/MainLayout.vue (2)
126-126: LGTM! Proper default value for injection.The explicit
nulldefault prevents SSR warnings when thesmoothScrollprovider is absent.
225-231: LGTM! Deprecated deep selector modernized.The change from
>>>to:deep()correctly addresses Vue 3 deprecation warnings.
This pull request fixes Vue 3 deprecation warnings and prevents SSR-related warnings by updating deprecated CSS selectors and adding proper default values for dependency injection.
Key changes:
>>>and/deep/combinators with:deep()pseudo-class inMainLayout.vueandIndexPage.vuenull) tosmoothScrollinject inMainLayout.vue,TeamPage.vue,IndexPage.vue, andProjectsPage.vueto prevent warnings during SSRThis ensures the development server runs without deprecation warnings and eliminates console warnings related to missing injections during server-side rendering.
Summary by CodeRabbit
Refactor
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.