-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: Position manager search and url generation not working #9219
base: develop
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
|
Typescript errors check862 ts errors detected in all the codebase 😟. Well done: no ts errors in files changed in this PR! 🎉 |
e3944ee
to
9845968
Compare
router.asPath, | ||
value | ||
? { | ||
[filterName]: encodeURIComponent(value.trim()), |
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.
updateQuery
will do the encode so no need to encode again
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.
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.
@@ -7,18 +7,26 @@ function filterHookFactory(filterName: string) { | |||
const router = useRouter() | |||
const filter = useMemo(() => { | |||
const value = router.query[filterName] | |||
if (Array.isArray(value)) { | |||
return value[0] | |||
if (value) { |
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.
It will break if I empty the search field?
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.
it will not break, value will be undefined therefore it will return all positions
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.
but if the value changed from a valid string to an empty string, the query won't get updated?
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.
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.
Fixed
9845968
to
76efb37
Compare
76efb37
to
94206ad
Compare
@chefjackson You can review it again |
const createSearchRegex = (wordText) => { | ||
const words = wordText.split(/\s+/) | ||
const escapedWords = words.map((word) => word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) | ||
const pattern = escapedWords.map((word) => `(?=.*\\b${word}\\b)`).join('') |
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.
Can we support partial search? For example I'd prefer to be able to search bnb
instead of typing wbnb
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.
Done
7fbacce
to
5441342
Compare
return decodeURIComponent(value[0]) | ||
} | ||
return decodeURIComponent(value) | ||
} | ||
return value | ||
return undefined | ||
}, [router.query]) | ||
|
||
const setFilter = useCallback( | ||
(value?: string) => { | ||
const trimmedValue = value?.trim() | ||
router.push( | ||
updateQuery(router.asPath, { | ||
[filterName]: value, | ||
[filterName]: trimmedValue && encodeURIComponent(trimmedValue), |
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.
I don't think we need to encode and decode again? updateQuery
is using url-parse
to parse and serialize the url, which uses querystringify
to encode and decode the querystring
https://github.com/pancakeswap/pancake-frontend/blob/develop/packages/utils/clientRouter.ts#L1-L17
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.
May I ask what's the bad case here?
178f136
to
7c7ef18
Compare
7c7ef18
to
b7bfe59
Compare
b7bfe59
to
1f3859a
Compare
1f3859a
to
cc209e7
Compare
be23492
to
48b672a
Compare
48b672a
to
0425128
Compare
0425128
to
9d1beb9
Compare
PR-Codex overview
The focus of this PR is to enhance filtering and searching functionalities in the PositionManagers feature.
Detailed summary