Skip to content
4 changes: 4 additions & 0 deletions packages/eui/changelogs/upcoming/8810.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**Bug fixes**

- Fixed an issue with `EuiSuperDatePicker` where toggling `isQuickSelectOnly` would cause a full re-render when the selected range uses absolute dates
Comment thread
mgadewoll marked this conversation as resolved.

Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export type EuiDatePickerRangeProps = CommonProps &
* Triggered whenever the start or end controls are focused
*/
onFocus?: FocusEventHandler<HTMLInputElement>;

/**
* If set to `true`, the delimeter and controls will be not be rendered
*/
isQuickSelectOnly?: boolean;
};

export const EuiDatePickerRange: FunctionComponent<EuiDatePickerRangeProps> = ({
Expand All @@ -116,6 +121,7 @@ export const EuiDatePickerRange: FunctionComponent<EuiDatePickerRangeProps> = ({
onBlur,
append,
prepend,
isQuickSelectOnly = false,
...rest
}) => {
// `fullWidth` and `compressed` should not affect inline datepickers (matches non-range behavior)
Expand Down Expand Up @@ -205,6 +211,7 @@ export const EuiDatePickerRange: FunctionComponent<EuiDatePickerRangeProps> = ({
return (
<span className={classes} css={cssStyles} {...rest}>
<EuiFormControlLayoutDelimited
isQuickSelectOnly={isQuickSelectOnly}
Comment thread
mgadewoll marked this conversation as resolved.
Outdated
icon={icon}
startControl={startControl}
endControl={endControl}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,15 +595,6 @@ export class EuiSuperDatePickerInternal extends Component<
],
};

if (isQuickSelectOnly) {
return (
<EuiFormControlLayout
iconsPosition="static"
{...formControlLayoutProps}
/>
);
}

const isDisabledDisplay = isObject(isDisabled) && isDisabled?.display;

if (
Expand All @@ -612,28 +603,30 @@ export class EuiSuperDatePickerInternal extends Component<
) {
return (
<EuiFormControlLayout {...formControlLayoutProps}>
<button
type="button"
css={styles.euiSuperDatePicker__prettyFormat}
className={classNames('euiSuperDatePicker__prettyFormat', {
'euiSuperDatePicker__prettyFormat--disabled': isDisabled,
})}
data-test-subj="superDatePickerShowDatesButton"
disabled={!!isDisabled}
onClick={this.hidePrettyDuration}
onFocus={onFocus}
>
{isDisabledDisplay ? (
isDisabled.display
) : (
<PrettyDuration
timeFrom={start}
timeTo={end}
quickRanges={commonlyUsedRanges}
dateFormat={dateFormat}
/>
)}
</button>
{!isQuickSelectOnly && (
Comment thread
mgadewoll marked this conversation as resolved.
<button
type="button"
css={styles.euiSuperDatePicker__prettyFormat}
className={classNames('euiSuperDatePicker__prettyFormat', {
'euiSuperDatePicker__prettyFormat--disabled': isDisabled,
})}
data-test-subj="superDatePickerShowDatesButton"
disabled={!!isDisabled}
onClick={this.hidePrettyDuration}
onFocus={onFocus}
>
{isDisabledDisplay ? (
isDisabled.display
) : (
<PrettyDuration
timeFrom={start}
timeTo={end}
quickRanges={commonlyUsedRanges}
dateFormat={dateFormat}
/>
)}
</button>
)}
</EuiFormControlLayout>
);
}
Expand All @@ -655,6 +648,7 @@ export class EuiSuperDatePickerInternal extends Component<
{({ locale: contextLocale }) => (
<EuiDatePickerRange
{...rangeProps}
isQuickSelectOnly={isQuickSelectOnly}
css={rangeCssStyles}
isCustom={true}
iconType={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export type EuiFormControlLayoutDelimitedProps =
*/
delimiter?: ReactNode;
className?: string;
/**
* If set to `true`, the delimeter and controls will be not be rendered
*/
isQuickSelectOnly?: boolean;
};

export const EuiFormControlLayoutDelimited: FunctionComponent<
Expand All @@ -51,6 +55,7 @@ export const EuiFormControlLayoutDelimited: FunctionComponent<
delimiter,
className,
fullWidth: _fullWidth,
isQuickSelectOnly = false,
...rest
}) => {
const { defaultFullWidth } = useFormContext();
Expand Down Expand Up @@ -86,12 +91,16 @@ export const EuiFormControlLayoutDelimited: FunctionComponent<
wrapperProps={{ ...rest.wrapperProps, css: wrapperStyles }}
>
<FormContext.Provider value={{ defaultFullWidth: fullWidth }}>
{addClassesToControl(startControl)}
<EuiFormControlDelimiter
delimiter={delimiter}
isInvalid={showInvalidState}
/>
{addClassesToControl(endControl)}
{!isQuickSelectOnly && (
<>
{addClassesToControl(startControl)}
<EuiFormControlDelimiter
delimiter={delimiter}
isInvalid={showInvalidState}
/>
{addClassesToControl(endControl)}
</>
)}
</FormContext.Provider>
</EuiFormControlLayout>
);
Expand Down