From 0df149aba3d440c0e646b65ae735392b00ff9e3d Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Wed, 19 Feb 2025 20:21:12 +0100 Subject: [PATCH] fix(explore): URL parameters override default value Signed-off-by: Erik Michelson --- frontend/src/hooks/common/use-url-param-state.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/hooks/common/use-url-param-state.ts b/frontend/src/hooks/common/use-url-param-state.ts index 5f681c68a..a26cfba6e 100644 --- a/frontend/src/hooks/common/use-url-param-state.ts +++ b/frontend/src/hooks/common/use-url-param-state.ts @@ -62,13 +62,16 @@ export const useUrlParamState = ( if (!searchParamsReact) { return } - const newValue = searchParamsReact.get(paramName) as T + let newValue = searchParamsReact.get(paramName) as T + if (newValue === null) { + newValue = typeof defaultValue === 'function' ? defaultValue() : defaultValue + } if (newValue === lastSetValue.current) { return } lastSetValue.current = newValue setValue(newValue) - }, [paramName, searchParamsReact]) + }, [paramName, searchParamsReact, defaultValue]) return [value, onUpdate] }