Skip to content
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

Upgrade EUI to v92.0.0 #174487

Merged
merged 9 commits into from
Jan 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* Side Public License, v 1.
*/

import React, { FC, useRef } from 'react';
import React, { FC } from 'react';
import { EuiInputPopover } from '@elastic/eui';
import { FROM_INDEX, TO_INDEX } from '../time_utils';
import { EuiDualRangeRef } from './time_slider_sliding_window_range';
import { getRoundedTimeRangeBounds } from '../time_slider_selectors';
import { useTimeSlider } from '../embeddable/time_slider_embeddable';
import { TimeSliderPopoverButton } from './time_slider_popover_button';
Expand Down Expand Up @@ -41,12 +40,6 @@ export const TimeSlider: FC<Props> = (props: Props) => {
return state.componentState.isOpen;
});

const rangeRef = useRef<EuiDualRangeRef>(null);

const onPanelResize = (width: number) => {
rangeRef.current?.onResize(width);
};
Comment on lines -44 to -48
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ref and method call were removed because EuiDualRange now contains its own resize observer and automatically adjusts its width accordingly.


const from = value ? value[FROM_INDEX] : timeRangeMin;
const to = value ? value[TO_INDEX] : timeRangeMax;

Expand All @@ -67,10 +60,8 @@ export const TimeSlider: FC<Props> = (props: Props) => {
isOpen={isOpen}
closePopover={() => timeSlider.dispatch.setIsOpen({ isOpen: false })}
panelPaddingSize="s"
onPanelResize={onPanelResize}
>
<TimeSliderPopoverContent
rangeRef={rangeRef}
value={[from, to]}
onChange={props.onChange}
stepSize={stepSize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* Side Public License, v 1.
*/

import React, { Ref } from 'react';
import React from 'react';
import { EuiButtonIcon, EuiRangeTick, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';

import { getIsAnchored } from '../time_slider_selectors';
import { TimeSliderStrings } from './time_slider_strings';
import { useTimeSlider } from '../embeddable/time_slider_embeddable';
import { TimeSliderAnchoredRange } from './time_slider_anchored_range';
import { EuiDualRangeRef, TimeSliderSlidingWindowRange } from './time_slider_sliding_window_range';
import { TimeSliderSlidingWindowRange } from './time_slider_sliding_window_range';

interface Props {
value: [number, number];
Expand All @@ -22,7 +22,6 @@ interface Props {
ticks: EuiRangeTick[];
timeRangeMin: number;
timeRangeMax: number;
rangeRef?: Ref<EuiDualRangeRef>;
}

export function TimeSliderPopoverContent(props: Props) {
Expand Down Expand Up @@ -55,7 +54,6 @@ export function TimeSliderPopoverContent(props: Props) {
value={props.value}
onChange={props.onChange}
stepSize={props.stepSize}
rangeRef={props.rangeRef}
ticks={ticks}
timeRangeMin={props.timeRangeMin}
timeRangeMax={props.timeRangeMax}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
* Side Public License, v 1.
*/

import React, { Ref, ComponentProps } from 'react';
import React from 'react';
import { EuiDualRange, EuiRangeTick } from '@elastic/eui';
import type { EuiDualRangeClass } from '@elastic/eui/src/components/form/range/dual_range';

// Unfortunately, wrapping EuiDualRange in `withEuiTheme` has created a super annoying/verbose typing
export type EuiDualRangeRef = EuiDualRangeClass & ComponentProps<typeof EuiDualRange>;

interface Props {
value: [number, number];
Expand All @@ -20,7 +16,6 @@ interface Props {
ticks: EuiRangeTick[];
timeRangeMin: number;
timeRangeMax: number;
rangeRef?: Ref<EuiDualRangeRef>;
}

export function TimeSliderSlidingWindowRange(props: Props) {
Expand All @@ -30,7 +25,6 @@ export function TimeSliderSlidingWindowRange(props: Props) {

return (
<EuiDualRange
ref={props.rangeRef}
fullWidth={true}
value={props.value}
onChange={onChange}
Expand Down