-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: always preserve marketplace search state in URL #22
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: cursor_combined_20260121_qodo_grep_cursor_copilot_1_base_refactor_always_preserve_marketplace_search_state_in_url_pr415
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import type { ActivePluginType } from './constants' | ||
| import type { PluginsSort, SearchParamsFromCollection } from './types' | ||
| import { atom, useAtom, useAtomValue, useSetAtom } from 'jotai' | ||
| import { useQueryState } from 'nuqs' | ||
|
|
@@ -17,32 +16,14 @@ export function useSetMarketplaceSort() { | |
| return useSetAtom(marketplaceSortAtom) | ||
| } | ||
|
|
||
| /** | ||
| * Preserve the state for marketplace | ||
| */ | ||
| export const preserveSearchStateInQueryAtom = atom<boolean>(false) | ||
|
|
||
| const searchPluginTextAtom = atom<string>('') | ||
| const activePluginTypeAtom = atom<ActivePluginType>('all') | ||
| const filterPluginTagsAtom = atom<string[]>([]) | ||
|
|
||
| export function useSearchPluginText() { | ||
| const preserveSearchStateInQuery = useAtomValue(preserveSearchStateInQueryAtom) | ||
| const queryState = useQueryState('q', marketplaceSearchParamsParsers.q) | ||
| const atomState = useAtom(searchPluginTextAtom) | ||
| return preserveSearchStateInQuery ? queryState : atomState | ||
| return useQueryState('q', marketplaceSearchParamsParsers.q) | ||
| } | ||
| export function useActivePluginType() { | ||
| const preserveSearchStateInQuery = useAtomValue(preserveSearchStateInQueryAtom) | ||
| const queryState = useQueryState('category', marketplaceSearchParamsParsers.category) | ||
| const atomState = useAtom(activePluginTypeAtom) | ||
| return preserveSearchStateInQuery ? queryState : atomState | ||
| return useQueryState('tab', marketplaceSearchParamsParsers.category) | ||
| } | ||
| export function useFilterPluginTags() { | ||
| const preserveSearchStateInQuery = useAtomValue(preserveSearchStateInQueryAtom) | ||
| const queryState = useQueryState('tags', marketplaceSearchParamsParsers.tags) | ||
| const atomState = useAtom(filterPluginTagsAtom) | ||
| return preserveSearchStateInQuery ? queryState : atomState | ||
| return useQueryState('tags', marketplaceSearchParamsParsers.tags) | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -59,7 +40,7 @@ export function useMarketplaceSearchMode() { | |
| const searchMode = useAtomValue(searchModeAtom) | ||
| const isSearchMode = !!searchPluginText | ||
| || filterPluginTags.length > 0 | ||
| || (searchMode ?? (!PLUGIN_CATEGORY_WITH_COLLECTIONS.has(activePluginType))) | ||
| || (searchMode ?? (PLUGIN_CATEGORY_WITH_COLLECTIONS.has(activePluginType))) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Search mode logic inverted, breaking collection displayHigh Severity The negation operator was accidentally removed from the search mode condition. The comment states that search mode needs to be forced for categories without collections, but the new code |
||
| return isSearchMode | ||
| } | ||
|
|
||
|
|
||
This file was deleted.
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.
Client-server URL parameter name mismatch for category
High Severity
useActivePluginType()now uses'tab'as the URL query parameter, but the server-side hydration inhydration-server.tsxreads fromparams.category(the key inmarketplaceSearchParamsParsers). This mismatch means server-side prefetching won't recognize thetabparameter, causing hydration failures and incorrect data loading when users navigate with category-filtered URLs.