-
Notifications
You must be signed in to change notification settings - Fork 239
fix: use unique keys for modules #2173
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
base: main
Are you sure you want to change the base?
Conversation
|
@aidanhibbard is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
π WalkthroughWalkthroughThe ModuleItem usage in the module grid was modified: the Estimated code review effortπ― 2 (Simple) | β±οΈ ~10 minutes π₯ Pre-merge checks | β 3β Passed checks (3 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing touchesπ§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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: 1
π€ Fix all issues with AI agents
In `@app/pages/modules/index.vue`:
- Around line 259-261: The add/remove tracking logic is inconsistent: the
is-added check uses object identity while removal uses name matching, causing
incorrect UI when module references change; update the is-added binding and
add/remove handlers for the module list (variables/components: displayedModules,
modulesToAdd, the is-added prop, and the `@add/`@remove handlers) to use
name-based matching (e.g., use modulesToAdd.some(m => m.name === module.name)
for is-added, push by module name or object, and filter by m.name !==
module.name on remove) and either validate/document that module.name is unique
(used as slug) so name-based identity is safe.
π§Ή Nitpick comments (1)
app/pages/modules/index.vue (1)
262-265: Align selection checks with name-based add/remove.
@removenow uses name matching, but:is-addedand@addstill depend on object identity. If module objects are re-instantiated (e.g., after refetch or filter rebuild), the UI can show βnot addedβ and allow duplicates. Consider switching to name-based checks and de-duping on add.β»οΈ Suggested adjustment
- :is-added="modulesToAdd.includes(module)" - `@add`="modulesToAdd.push(module)" + :is-added="modulesToAdd.some(m => m.name === module.name)" + `@add`="modulesToAdd.some(m => m.name === module.name) || modulesToAdd.push(module)" `@remove`="modulesToAdd = modulesToAdd.filter(m => m.name !== module.name)"
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
The main issue here is that this page is pre-rendered, so changing this will create and hydration mismatch. See https://nuxt-git-fork-aidanhibbard-main-nuxt-js.vercel.app/modules?category=Security |
|
Heard, will pick this back up later today. Appreciate the catch :) |
|
What would be your ideal here? Do we want to call init modules on mounted, and, or add the ClientOnly barrier? I guess I didn't realize there are pre-rendered pages. |
π Linked issue
Resolves 2164
β Type of change
π Description
Uses unique keys for modules rendering to resolve issues including improper links in some cases.