Skip to content

fix(ui/dashboard): experiment filter search params - #2123

Merged
cre8ivejp merged 2 commits into
mainfrom
fix-experiment-filter-search-params
Sep 17, 2025
Merged

fix(ui/dashboard): experiment filter search params#2123
cre8ivejp merged 2 commits into
mainfrom
fix-experiment-filter-search-params

Conversation

@steveninhle

Copy link
Copy Markdown
Collaborator

No description provided.

@steveninhle steveninhle changed the title fix: experiment filter search params fix(ui/dashboard): experiment filter search params Sep 15, 2025
@steveninhle
steveninhle marked this pull request as ready for review September 16, 2025 08:09
@cre8ivejp
cre8ivejp requested a review from Copilot September 17, 2025 09:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes search parameter handling for experiment filters in the dashboard UI, addressing issues with filter state management and URL synchronization.

  • Updates useSearchParams hook dependency array to include navigate and location for proper re-computation
  • Refactors experiment filter handling to improve state consistency and remove redundant optional chaining
  • Simplifies filter update logic in onChangeFilters callback

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
ui/dashboard/src/utils/search-params.ts Updates useMemo dependencies to fix search params reactivity
ui/dashboard/src/pages/experiments/page-content.tsx Refactors filter handling logic and removes unnecessary optional chaining

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread ui/dashboard/src/utils/search-params.ts Outdated
const searchOptions = useMemo<SearchParams>((): SearchParams => {
return queryString.parse(location.search);
}, [location.search]);
}, [navigate, location]);

Copilot AI Sep 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency array includes navigate but this function is typically stable and doesn't need to be a dependency. Including it may cause unnecessary re-computations. Consider removing navigate from the dependencies and keeping only location.search to maintain the original intent of re-parsing when the search string changes.

Suggested change
}, [navigate, location]);
}, [location.search]);

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed e829d78

const merged = { ...filters, ...values, page: nextPage };
const options = pickBy(merged, v => isNotEmpty(v));
if (isChangeParams) onChangSearchParams(options);
setFilters(merged);

Copilot AI Sep 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setFilters call uses merged which includes all filter properties, but the original code used { ...values } which only set the changed values. This change could overwrite filter state that wasn't intended to be modified, potentially causing unexpected behavior when partial updates are made.

Suggested change
setFilters(merged);
setFilters(values);

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed e829d78

@cre8ivejp cre8ivejp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@cre8ivejp
cre8ivejp merged commit 8489257 into main Sep 17, 2025
3 checks passed
@cre8ivejp
cre8ivejp deleted the fix-experiment-filter-search-params branch September 17, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants