-
Notifications
You must be signed in to change notification settings - Fork 15
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(KFLUXUI-312): add useSearchParamBatch hook for batch params operations #107
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #107 +/- ##
==========================================
+ Coverage 80.06% 80.08% +0.02%
==========================================
Files 544 544
Lines 21155 21195 +40
Branches 5326 5335 +9
==========================================
+ Hits 16937 16975 +38
- Misses 4194 4195 +1
- Partials 24 25 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
src/hooks/useSearchParam.ts
Outdated
(names?: string[]) => { | ||
const result: Record<string, string> = {}; | ||
|
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.
(names?: string[]) => { | |
const result: Record<string, string> = {}; | |
(names?: string[]) => { | |
If (name === undefined) return Object.fromEntries(searchParams); | |
if (typeof name === 'string') return searchParams.get(name); | |
const result: Record<string, string> = {}; | |
src/hooks/useSearchParam.ts
Outdated
); | ||
|
||
const batchUnset = React.useCallback( | ||
(names?: string[]) => { |
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.
(names?: string[]) => { | |
(names: string[]) => { |
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.
Since adding a set of managed params, I think it makes sense to keep the option to unset all the params without specifying them. Only the managed ones will be deleted
src/hooks/useSearchParam.ts
Outdated
@@ -45,3 +45,54 @@ export const useSearchParam = ( | |||
|
|||
return [value, set, unset]; | |||
}; | |||
|
|||
export const useSearchParamBatch = (): [ |
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.
should we allow passing a set of keys that the hook should manage?
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.
yeah, that makes sense. I added it in the latest commit
Fixes
KFLUXUI-312
Description
Hook for batch search params operation, fixes the issue where if multiple params were set separately only one of the operation had effect. Will be used in components in this PR
Type of change
Screen shots / Gifs for design review
How to test or reproduce?
Browser conformance: