Skip to content

Commit e7e6e84

Browse files
committed
fix(webapp): keep controlled TimeFilter from falling back to the URL
When TimeFilter is used in controlled mode (onValueChange provided), it now takes period/from/to only from props instead of falling back to the URL search params. Selecting a custom date range in the model detail panel (which sets period to undefined) no longer reverts the filter display to the page-level URL period.
1 parent f5ac92a commit e7e6e84

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

apps/webapp/app/components/runs/v3/SharedFilters.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,13 @@ export function TimeFilter({
375375
valueClassName,
376376
}: TimeFilterProps = {}) {
377377
const { value } = useSearchParams();
378-
const periodValue = period ?? value("period");
379-
const fromValue = from ?? value("from");
380-
const toValue = to ?? value("to");
378+
// In controlled mode (onValueChange provided) the caller owns all three values via local
379+
// state, so don't fall back to the URL — otherwise selecting a custom date range (which
380+
// sets period to undefined) would read the page-level URL period and override the range.
381+
const controlled = onValueChange !== undefined;
382+
const periodValue = controlled ? period : period ?? value("period");
383+
const fromValue = controlled ? from : from ?? value("from");
384+
const toValue = controlled ? to : to ?? value("to");
381385
const triggerRef = useRef<HTMLButtonElement>(null);
382386

383387
useShortcutKeys({

0 commit comments

Comments
 (0)