Skip to content

Commit

Permalink
[EuiSuperDatePicker] Fix dates overflowing out of the delimited inputs (
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Nov 1, 2024
1 parent bceb329 commit 4bf3655
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions packages/eui/.storybook/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const customWithin = (canvasElement: HTMLElement) => {
await waitFor(() =>
expect(canvasElement.querySelector('[data-popover-open]')).toBeVisible()
),
waitForEuiPopoverHidden: async () =>
await waitFor(() =>
expect(
canvasElement.querySelector('[data-popover-panel]')
).not.toBeInTheDocument()
),
};
};

Expand Down
3 changes: 3 additions & 0 deletions packages/eui/changelogs/upcoming/8109.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed an `EuiSuperDatePicker` bug where inputs would overflow out of smaller widths instead of truncating
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ exports[`EuiSuperDatePicker renders an EuiDatePickerRange 1`] = `
</span>
</div>
<div
class="euiPopover euiFormControlLayoutDelimited__input emotion-euiPopover-block-euiFormControlLayoutDelimited__input-euiSuperDatePicker__rangeInput"
class="euiPopover euiFormControlLayoutDelimited__input emotion-euiPopover-block-now-euiFormControlLayoutDelimited__input-euiSuperDatePicker__rangeInput"
>
<button
class="euiDatePopoverButton euiDatePopoverButton--end emotion-euiDatePopoverButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ export const euiDatePopoverButtonStyles = (euiThemeContext: UseEuiTheme) => {
euiDatePopoverButton: css`
${_buttonStyles(euiThemeContext)}
`,
now: css`
/* !important needed to override date range picker nested styles */
flex-grow: 0.5 !important; /* stylelint-disable-line declaration-no-important */
`,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export const EuiDatePopoverButton: FunctionComponent<
display="block"
panelPaddingSize="none"
{...rest}
css={value === 'now' && styles.now}
>
<EuiDatePopoverContent
value={value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import moment from 'moment';
import type { Meta, StoryObj } from '@storybook/react';
import { expect } from '@storybook/test';
import { expect, fireEvent } from '@storybook/test';
import { within } from '../../../../.storybook/test';
import { LOKI_SELECTORS } from '../../../../.storybook/loki';
import { enableFunctionToggleControls } from '../../../../.storybook/utils';
Expand Down Expand Up @@ -123,3 +123,33 @@ function CustomPanel({ applyTime }: { applyTime?: ApplyTime }) {
<EuiLink onClick={applyMyCustomTime}>Entire dataset timerange</EuiLink>
);
}

/**
* VRT only
*/
export const OverflowingChildren: Story = {
tags: ['vrt-only'],
args: { start: 'Dec 31, 1999' },
decorators: [
(Story) => (
<div style={{ maxWidth: 400 }}>
<Story />
</div>
),
],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);

const startButton = canvas.getByTestSubject(
'superDatePickerstartDatePopoverButton'
);
const getAbsoluteTab = () =>
canvas.getByTestSubject('superDatePickerAbsoluteTab');

await fireEvent.click(startButton);
await canvas.waitForEuiPopoverVisible();
await fireEvent.click(getAbsoluteTab());
await fireEvent.click(startButton);
await canvas.waitForEuiPopoverHidden();
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const euiSuperDatePickerStyles = (euiThemeContext: UseEuiTheme) => {
euiSuperDatePicker__rangeInput: css`
flex-grow: 1;
${logicalCSS('width', 'auto')}
overflow: hidden;
`,
euiSuperDatePicker__prettyFormat: css`
${_buttonStyles(euiThemeContext)}
Expand Down

0 comments on commit 4bf3655

Please sign in to comment.