Skip to content

Commit

Permalink
RC #291 - Updating to set default min/max values after async load
Browse files Browse the repository at this point in the history
  • Loading branch information
dleadbetter committed Aug 13, 2024
1 parent 11681a1 commit 728b567
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/core-data/src/components/FacetTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ const FacetTimeline = (props: Props) => {
const { range = {}, refine, start = [] } = props.useRange({ attribute: FACET_EVENT_RANGE });

const [events, setEvents] = useState();
const [defaultMax] = useState(range.max);
const [defaultMin] = useState(range.min);
const [defaultMax, setDefaultMax] = useState(range.max);
const [defaultMin, setDefaultMin] = useState(range.min);
const [max, setMax] = useState(range.max);
const [min, setMin] = useState(range.min);
const [value, setValue] = useState([min, max]);
Expand Down Expand Up @@ -213,8 +213,16 @@ const FacetTimeline = (props: Props) => {
const to = Math.min(range.max, Number.isFinite(start[1]) ? start[1] : range.max);

setValue([from, to]);
setMax(range.max);
setMin(range.min);
setMax(range.max);

if (!defaultMin && range.min) {
setDefaultMin(range.min);
}

if (!defaultMax && range.max) {
setDefaultMax(range.max);
}
}, [range.min, range.max]);

return (
Expand Down

0 comments on commit 728b567

Please sign in to comment.