Skip to content

feat: make workspace search bar remember text #9759

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

Merged
merged 17 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: Rename initialValue to fallbackFilter
  • Loading branch information
Parkreiner committed Sep 19, 2023
commit ab9de0cc31bf8d45bf325e8f70dae6269c9bb806
9 changes: 5 additions & 4 deletions site/src/components/Filter/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ type FilterValues = Record<string, string | undefined>;

type UseFilterConfig = {
/**
* The fallback value to use in the event that no filter params can be used.
* This value is allowed to change on re-renders.
* The fallback value to use in the event that no filter params can be parsed
* from the search params object. This value is allowed to change on
* re-renders.
*/
initialValue?: string;
fallbackFilter?: string;
searchParamsResult: ReturnType<typeof useSearchParams>;
onUpdate?: (newValue: string) => void;
};

const useFilterParamsKey = "filter";

export const useFilter = ({
initialValue: fallbackFilter = "",
fallbackFilter = "",
searchParamsResult,
onUpdate,
}: UseFilterConfig) => {
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/WorkspacesPage/WorkspacesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const useWorkspacesFilter = ({
/**
* @todo Rename initialValue to fallbackFilter once changes have been tested
*/
initialValue: localStorageFilter,
fallbackFilter: localStorageFilter,
searchParamsResult,
onUpdate: (newValues) => {
window.localStorage.setItem(workspaceFilterKey, newValues);
Expand Down