Skip to content
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
2 changes: 2 additions & 0 deletions packages/eui/changelogs/upcoming/9221.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Updated `EuiSuperDatePicker` to show a tooltip with the full range details when the button displays a pretty duration e.g. "Last 15 minutes"

Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,21 @@ exports[`EuiSuperDatePicker props accepts data-test-subj and passes to EuiFormCo
<div
class="euiFormControlLayout__childrenWrapper emotion-euiFormControlLayout__childrenWrapper-inGroup-prependOnly"
>
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth-euiSuperDatePicker__prettyFormat"
data-test-subj="superDatePickerShowDatesButton"
type="button"
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-block"
>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth"
data-test-subj="superDatePickerShowDatesButton"
type="button"
>
Last 15 minutes
</span>
</button>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
>
Last 15 minutes
</span>
</button>
</span>
</div>
</div>
<span
Expand Down Expand Up @@ -119,17 +123,21 @@ exports[`EuiSuperDatePicker props compressed is rendered 1`] = `
<div
class="euiFormControlLayout__childrenWrapper emotion-euiFormControlLayout__childrenWrapper-inGroup-prependOnly"
>
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth-euiSuperDatePicker__prettyFormat"
data-test-subj="superDatePickerShowDatesButton"
type="button"
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-block"
>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-compressed-fullWidth"
data-test-subj="superDatePickerShowDatesButton"
type="button"
>
Last 15 minutes
</span>
</button>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
>
Last 15 minutes
</span>
</button>
</span>
</div>
</div>
<span
Expand Down Expand Up @@ -264,7 +272,7 @@ exports[`EuiSuperDatePicker props isAutoRefreshOnly passes required props 1`] =

exports[`EuiSuperDatePicker props isDisabled config object 1`] = `
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat euiSuperDatePicker__prettyFormat--disabled emotion-euiButtonDisplay-euiButtonEmpty-m-empty-disabled-isDisabled-euiFormControlButton-fullWidth-euiSuperDatePicker__prettyFormat"
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat euiSuperDatePicker__prettyFormat--disabled emotion-euiButtonDisplay-euiButtonEmpty-m-empty-disabled-isDisabled-euiFormControlButton-fullWidth"
data-test-subj="superDatePickerShowDatesButton"
disabled=""
type="button"
Expand Down Expand Up @@ -323,18 +331,22 @@ exports[`EuiSuperDatePicker props isDisabled true 1`] = `
<div
class="euiFormControlLayout__childrenWrapper emotion-euiFormControlLayout__childrenWrapper-inGroup-prependOnly"
>
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat euiSuperDatePicker__prettyFormat--disabled emotion-euiButtonDisplay-euiButtonEmpty-m-empty-disabled-isDisabled-euiFormControlButton-fullWidth-euiSuperDatePicker__prettyFormat"
data-test-subj="superDatePickerShowDatesButton"
disabled=""
type="button"
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-block"
>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat euiSuperDatePicker__prettyFormat--disabled emotion-euiButtonDisplay-euiButtonEmpty-m-empty-disabled-isDisabled-euiFormControlButton-fullWidth"
data-test-subj="superDatePickerShowDatesButton"
disabled=""
type="button"
>
Last 15 minutes
</span>
</button>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
>
Last 15 minutes
</span>
</button>
</span>
</div>
</div>
<span
Expand Down Expand Up @@ -467,17 +479,21 @@ exports[`EuiSuperDatePicker props showUpdateButton can be false 1`] = `
<div
class="euiFormControlLayout__childrenWrapper emotion-euiFormControlLayout__childrenWrapper-inGroup-prependOnly"
>
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth-euiSuperDatePicker__prettyFormat"
data-test-subj="superDatePickerShowDatesButton"
type="button"
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-block"
>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth"
data-test-subj="superDatePickerShowDatesButton"
type="button"
>
Last 15 minutes
</span>
</button>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
>
Last 15 minutes
</span>
</button>
</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -524,17 +540,21 @@ exports[`EuiSuperDatePicker props showUpdateButton can be iconOnly 1`] = `
<div
class="euiFormControlLayout__childrenWrapper emotion-euiFormControlLayout__childrenWrapper-inGroup-prependOnly"
>
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth-euiSuperDatePicker__prettyFormat"
data-test-subj="superDatePickerShowDatesButton"
type="button"
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-block"
>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth"
data-test-subj="superDatePickerShowDatesButton"
type="button"
>
Last 15 minutes
</span>
</button>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
>
Last 15 minutes
</span>
</button>
</span>
</div>
</div>
<span
Expand Down Expand Up @@ -604,17 +624,21 @@ exports[`EuiSuperDatePicker props width can be auto 1`] = `
<div
class="euiFormControlLayout__childrenWrapper emotion-euiFormControlLayout__childrenWrapper-inGroup-prependOnly"
>
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth-euiSuperDatePicker__prettyFormat"
data-test-subj="superDatePickerShowDatesButton"
type="button"
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-block"
>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth"
data-test-subj="superDatePickerShowDatesButton"
type="button"
>
Last 15 minutes
</span>
</button>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
>
Last 15 minutes
</span>
</button>
</span>
</div>
</div>
<span
Expand Down Expand Up @@ -681,17 +705,21 @@ exports[`EuiSuperDatePicker props width can be full 1`] = `
<div
class="euiFormControlLayout__childrenWrapper emotion-euiFormControlLayout__childrenWrapper-inGroup-prependOnly"
>
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth-euiSuperDatePicker__prettyFormat"
data-test-subj="superDatePickerShowDatesButton"
type="button"
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-block"
>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth"
data-test-subj="superDatePickerShowDatesButton"
type="button"
>
Last 15 minutes
</span>
</button>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
>
Last 15 minutes
</span>
</button>
</span>
</div>
</div>
<span
Expand Down Expand Up @@ -759,17 +787,21 @@ exports[`EuiSuperDatePicker renders 1`] = `
<div
class="euiFormControlLayout__childrenWrapper emotion-euiFormControlLayout__childrenWrapper-inGroup-prependOnly"
>
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth-euiSuperDatePicker__prettyFormat"
data-test-subj="superDatePickerShowDatesButton"
type="button"
<span
class="euiToolTipAnchor emotion-euiToolTipAnchor-block"
>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
<button
class="euiButtonEmpty euiFormControlButton euiSuperDatePicker__prettyFormat emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-euiFormControlButton-fullWidth"
data-test-subj="superDatePickerShowDatesButton"
type="button"
>
Last 15 minutes
</span>
</button>
<span
class="euiButtonEmpty__content emotion-euiButtonDisplayContent-euiFormControlButton__content"
>
Last 15 minutes
</span>
</button>
</span>
</div>
</div>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,8 @@ export const euiSuperDatePickerStyles = (euiThemeContext: UseEuiTheme) => {
${logicalCSS('width', 'auto')}
overflow: hidden;
`,
euiSuperDatePicker__prettyFormat: css`
${_buttonStyles(euiThemeContext)}
text-align: start;

--euiFormControlStateHoverColor: ${forms.borderHovered};
${euiFormControlDefaultShadow(euiThemeContext)}

&:focus {
${euiFormControlFocusStyles(euiThemeContext)}
}

${highContrastModeStyles(euiThemeContext, {
preferred: `
border: none;
`,
})}
euiSuperDatePicker__prettyDurationTooltip: css`
${logicalCSS('max-width', 'min(58ch, 90vw)')}
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a neat trick, I like it 👍🏻

`,

// Form states
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,38 @@ describe('EuiSuperDatePicker', () => {
});
});

test('pretty duration button has full range tooltip', async () => {
const now = moment('1999-12-31');
const dateFormat = 'MMM D, HH:mm:ss';

jest.useFakeTimers().setSystemTime(now.toDate());

const { getByTestSubject, findByRole } = render(
<EuiSuperDatePicker
onTimeChange={noop}
start="now-15m"
end="now"
dateFormat={dateFormat}
/>
);

// needs to be async to support React 17
await act(async () => {
userEvent.hover(getByTestSubject('superDatePickerShowDatesButton'));
});

const tooltip = await findByRole('tooltip');

const end = now.format(dateFormat);
const start = now.clone().subtract(15, 'minutes').format(dateFormat);
const formattedValue = `${start} – ${end}`;

expect(tooltip).toBeInTheDocument();
expect(tooltip).toHaveTextContent(formattedValue);

jest.useRealTimers();
});

describe('Quick Select time window steps', () => {
it('steps forward', async () => {
// Use fixed absolute start/end with time
Expand Down
Loading