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

[EuiSuperDatePicker] Fix dates overflowing out of the delimited inputs #8109

Merged
merged 4 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading