fix: add back button and centre icon on compare page#941
fix: add back button and centre icon on compare page#941danielroe merged 3 commits intonpmx-dev:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
📝 WalkthroughWalkthroughUpdates three Compare-area components: FacetCard.vue now wraps the header info icon with a TooltipApp when a description exists; PackageSelector.vue adds flex alignment classes to the remove-package close icon span; compare.vue obtains a router instance via useRouter() for template navigation (e.g., back()) and adds horizontal padding to the empty-state layout. Possibly related PRs
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
app/components/Compare/FacetCard.vue (1)
78-84: Consider removing the redundanttitleattribute.The span has both
:title="description"and is wrapped inTooltipAppwith:text="description". This may cause two tooltips to appear on desktop hover (the native browser tooltip fromtitleand the custom tooltip fromTooltipApp).♻️ Suggested fix
<TooltipApp v-if="description" :text="description" position="top"> <span class="i-carbon:information w-3 h-3 text-fg-subtle" - :title="description" aria-hidden="true" /> </TooltipApp>app/pages/compare.vue (2)
67-68: Remove duplicatemb-4from the heading.The
h1hasmb-4but its parentdivat line 66 also hasmb-4. This creates unintended extra spacing. Since the parent container already provides the bottom margin, themb-4on the heading appears to be a leftover from before the layout change.♻️ Suggested fix
- <h1 class="font-mono text-3xl sm:text-4xl font-medium mb-4"> + <h1 class="font-mono text-3xl sm:text-4xl font-medium">
72-72: Remove inlinefocus-visibleutility class from the button.The project uses global CSS for button focus-visible styling. Per coding guidelines, buttons should rely on the global rule in
main.cssrather than inline utility classes likefocus-visible:outline-accent/70.♻️ Suggested fix
- class="inline-flex items-center gap-2 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0" + class="inline-flex items-center gap-2 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded shrink-0"Based on learnings: "focus-visible styling for buttons and selects is applied globally via main.css... individual buttons or selects in Vue components should not rely on inline focus-visible utility classes."
| <button | ||
| type="button" | ||
| class="inline-flex items-center gap-2 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0" | ||
| @click="router.back()" | ||
| > | ||
| <span class="i-carbon:arrow-left rtl-flip w-4 h-4" aria-hidden="true" /> | ||
| <span class="hidden sm:inline">{{ $t('nav.back') }}</span> | ||
| </button> |
There was a problem hiding this comment.
router.back() may navigate users out of the site.
If a user navigates directly to the compare page (e.g., via a shared link), there's no history entry within the app. Calling router.back() would take them to their previous site or an empty tab, which is poor UX.
Consider using a fallback to a known route:
🛡️ Suggested fix with fallback
- `@click`="router.back()"
+ `@click`="window.history.length > 1 ? router.back() : router.push('/')"Alternatively, if there's a referrer check or you want to always navigate to a specific page (like the homepage), you could simplify to router.push('/').
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <button | |
| type="button" | |
| class="inline-flex items-center gap-2 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0" | |
| @click="router.back()" | |
| > | |
| <span class="i-carbon:arrow-left rtl-flip w-4 h-4" aria-hidden="true" /> | |
| <span class="hidden sm:inline">{{ $t('nav.back') }}</span> | |
| </button> | |
| <button | |
| type="button" | |
| class="inline-flex items-center gap-2 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0" | |
| `@click`="window.history.length > 1 ? router.back() : router.push('/')" | |
| > | |
| <span class="i-carbon:arrow-left rtl-flip w-4 h-4" aria-hidden="true" /> | |
| <span class="hidden sm:inline">{{ $t('nav.back') }}</span> | |
| </button> |
There was a problem hiding this comment.
Indeed, I didn't anticipate directly entering the compare page. Should we adopt the solution he mentioned?
There was a problem hiding this comment.
@RYGRIT Yes, I recommend adopting the suggested solution! Here's why:
The Problem:
When users arrive at the compare page via a direct link (shared URL, bookmark, etc.), calling router.back() would navigate them away from your site entirely—poor UX.
The Solution:
`@click`="window.history.length > 1 ? router.back() : router.push('/')"This checks if there's navigation history before going back. If not, it safely redirects to the homepage.
Why it works:
- ✅ Users who navigated within the app get expected back behavior
- ✅ Users arriving from external sources stay on your site (go to homepage)
- ✅ Simple, minimal code change
- ✅ Follows common UX patterns
The fallback to / (homepage) makes sense as a safe default. Go ahead and implement it! 👍
🧠 Learnings used
Learnt from: alexdln
Repo: npmx-dev/npmx.dev PR: 838
File: app/pages/package/[...package].vue:445-449
Timestamp: 2026-02-03T13:59:33.392Z
Learning: The copy button pattern in app/pages/package/[...package].vue may be made into a reusable component or pattern in the future, but currently it's acceptable to keep it inline with the CSS-only approach for smooth animations.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
this pr:
related issues: #918