Skip to content

Commit

Permalink
RC #291 - Refactoring setting the FacetTimeline value
Browse files Browse the repository at this point in the history
  • Loading branch information
dleadbetter committed Aug 14, 2024
1 parent 1ba490b commit 2339d4d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core-data/src/components/FacetTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ const FACET_EVENT_RANGE = 'event_range_facet';
const FacetTimeline = (props: Props) => {
const { range = {}, refine, start = [] } = props.useRange({ attribute: FACET_EVENT_RANGE });

const from = Math.max(range.min, Number.isFinite(start[0]) ? start[0] : range.min);
const to = Math.min(range.max, Number.isFinite(start[1]) ? start[1] : range.max);

const [events, setEvents] = useState();
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]);
const [value, setValue] = useState([from, to]);

const EventsService = useEventsService();
const ref = useRef();
Expand Down Expand Up @@ -230,9 +233,6 @@ const FacetTimeline = (props: Props) => {
* When the upper and/or lower bounds of the range change, update the value and min/max values.
*/
useEffect(() => {
const from = Math.max(range.min, Number.isFinite(start[0]) ? start[0] : range.min);
const to = Math.min(range.max, Number.isFinite(start[1]) ? start[1] : range.max);

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

0 comments on commit 2339d4d

Please sign in to comment.