Skip to content

Commit

Permalink
Fix re-rendering bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Jun 17, 2024
1 parent b8af895 commit 22a699b
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions code/ui/manager/src/components/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ const useCombination = (
return useMemo(() => ({ hash, entries: Object.entries(hash) }), [hash]);
};

const updateQueryParams = (params: Record<string, string>) => {
const url = new URL(window.location.href);
Object.entries(params).forEach(([key, value]) => {
if (value) {
url.searchParams.set(key, value);
} else {
url.searchParams.delete(key);
}
});
window.history.pushState({}, '', url);
};
export interface SidebarProps extends API_LoadedRefData {
refs: State['refs'];
status: State['status'];
Expand Down Expand Up @@ -152,23 +163,7 @@ export const Sidebar = React.memo(function Sidebar({
isLoading={isLoading}
onMenuClick={onMenuClick}
/>
{index && (
<TagsFilter
api={api}
index={index}
updateQueryParams={(params) => {
const url = new URL(window.location.href);
Object.entries(params).forEach(([key, value]) => {
if (value) {
url.searchParams.set(key, value);
} else {
url.searchParams.delete(key);
}
});
window.history.pushState({}, '', url);
}}
/>
)}
{index && <TagsFilter api={api} index={index} updateQueryParams={updateQueryParams} />}
<Search
dataset={dataset}
enableShortcuts={enableShortcuts}
Expand Down

0 comments on commit 22a699b

Please sign in to comment.