-
Notifications
You must be signed in to change notification settings - Fork 886
[EuiSuperDatePicker] Time zone display #9191
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
Merged
acstll
merged 27 commits into
elastic:feat/super-date-picker-track-1-ms-1
from
acstll:super-date-picker-timezone-display
Nov 12, 2025
Merged
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
ae6cdbb
[EuiTimeZoneDisplay] New component
acstll 0237cd1
[EuiSuperDatePicker] Integrate time zone display
acstll acbd81d
[EuiTimeZoneDisplay] locale not actually needed
acstll 9bf0081
[EuiTimeZoneDisplay] Add story
acstll 34a77ea
[TimeWindowButtons] Try fixing flaky test
acstll f51c969
Lint, remove smoke testing leftover
acstll 91c3751
[EuiTimeZoneDisplay] Rename hook and add eui prefix
acstll 7748688
TODO comment
acstll 216f083
[EuiTimeZoneDisplay] Add unit tests
acstll f0a2a79
Update VRT
acstll 954232f
[Docs] Time zone display
acstll 58d8029
Lint
acstll 1028a20
Changelog
acstll 651d787
[TimeWindowButtons] Try fixing flaky test 2
acstll dcce4f0
[TimeWindowButtons] Try fixing flaky test 3
acstll cf487a8
[EuiTimeZoneDisplay] Refactor props, use timeZoneDisplayProps
acstll 9a20e95
[Docs] Add missing aria-label to EuiButtonIcon
acstll a990bf5
[EuiTimeZoneDisplay] Link inputs via aria-describedby
acstll bb9904b
[EuiSuperDatePicker] Show time zone by default in stories
acstll 3d010a3
[Docs] Update time zone bit
acstll 4219bbc
Polish comments, JSDoc
acstll 325881e
Update snapshots
acstll 5e32411
[Docs] Fix snippet
acstll b1737aa
Update changelog
acstll 64938bb
[Nit] Keep interface as it was
acstll dcda47f
Typo
acstll 7387079
Fix Storybook interaction
acstll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+28.4 KB
...esktop_Forms_EuiSuperDatePicker_EuiSuperDatePicker_Custom_Time_Zone_Display.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1 Byte
(100%)
...ome_desktop_Forms_EuiSuperDatePicker_EuiSuperDatePicker_Time_Window_Buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+53.3 KB
...mobile_Forms_EuiSuperDatePicker_EuiSuperDatePicker_Custom_Time_Zone_Display.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+103 Bytes
(100%)
...rome_mobile_Forms_EuiSuperDatePicker_EuiSuperDatePicker_Time_Window_Buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - Updated `EuiSuperDatePicker` with new time zone information, opt-in via `timeZoneDisplay`. | ||
|
|
22 changes: 22 additions & 0 deletions
22
...s/date_picker/super_date_picker/date_popover/__snapshots__/timezone_display.test.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`EuiTimeZoneDisplay renders 1`] = ` | ||
| <div> | ||
| <div | ||
| class="euiFlexGroup emotion-euiFlexGroup-responsive-xs-flexStart-center-row-euiTimeZoneDisplay" | ||
| data-test-subj="euiTimeZoneDisplay" | ||
| > | ||
| <span | ||
| color="subdued" | ||
| data-euiicon-type="globe" | ||
| /> | ||
| <span | ||
| class="euiText emotion-euiText-s-euiTextColor-subdued" | ||
| > | ||
| UTC-8 | ||
|
|
||
| (America/Los_Angeles) | ||
| </span> | ||
| </div> | ||
| </div> | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
.../eui/src/components/date_picker/super_date_picker/date_popover/timezone_display.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import { css } from '@emotion/react'; | ||
|
|
||
| import { UseEuiTheme } from '../../../../services'; | ||
| import { logicalCSS } from '../../../../global_styling'; | ||
|
|
||
| export const euiTimeZoneDisplayStyles = (euiThemeContext: UseEuiTheme) => { | ||
| const { euiTheme } = euiThemeContext; | ||
|
|
||
| // This padding should probably not be part of this component to make it really reusable | ||
|
|
||
| return { | ||
| euiTimeZoneDisplay: css` | ||
| ${logicalCSS('padding-horizontal', euiTheme.size.s)} | ||
| ${logicalCSS('padding-bottom', euiTheme.size.s)} | ||
| `, | ||
| }; | ||
| }; |
82 changes: 82 additions & 0 deletions
82
...s/eui/src/components/date_picker/super_date_picker/date_popover/timezone_display.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
|
|
||
| import { render } from '../../../../test/rtl'; | ||
|
|
||
| import { EuiTimeZoneDisplay } from './timezone_display'; | ||
|
|
||
| import { EuiButtonIcon } from '../../../button'; | ||
|
|
||
| describe('EuiTimeZoneDisplay', () => { | ||
| it('renders', () => { | ||
| const { container } = render( | ||
| <EuiTimeZoneDisplay timeZoneDisplay="America/Los_Angeles" /> | ||
| ); | ||
|
|
||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('handles "Browser" time zone name', () => { | ||
| const { getByTestSubject } = render( | ||
| <EuiTimeZoneDisplay timeZoneDisplay="Browser" /> | ||
| ); | ||
|
|
||
| const browserTimeZone = new Intl.DateTimeFormat().resolvedOptions() | ||
| .timeZone; | ||
|
|
||
| expect(getByTestSubject('euiTimeZoneDisplay')).toHaveTextContent( | ||
| browserTimeZone | ||
| ); | ||
| }); | ||
|
|
||
| it('handles "UTC" time zone name', () => { | ||
| const { getByTestSubject } = render( | ||
| <EuiTimeZoneDisplay timeZoneDisplay="UTC" /> | ||
| ); | ||
|
|
||
| // No name displayed between parenthesis, only "UTC" | ||
| expect(getByTestSubject('euiTimeZoneDisplay')).toHaveTextContent('UTC'); | ||
| }); | ||
|
|
||
| it('does not render with invalid time zone', () => { | ||
| const { queryByTestSubject } = render( | ||
| <EuiTimeZoneDisplay timeZoneDisplay="Foo/Bar" /> | ||
| ); | ||
|
|
||
| expect(queryByTestSubject('euiTimeZoneDisplay')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('timeZoneCustomDisplayRender render function', () => { | ||
| const customContent = ( | ||
| <EuiButtonIcon | ||
| href="https://example.com" | ||
| iconType="documentation" | ||
| data-test-subj="customContent" | ||
| /> | ||
| ); | ||
|
|
||
| const { getByTestSubject } = render( | ||
| <EuiTimeZoneDisplay | ||
| timeZoneDisplay="Europe/Helsinki" | ||
| timeZoneCustomDisplayRender={({ nameDisplay }) => ( | ||
| <> | ||
| {nameDisplay} | ||
| {customContent} | ||
| </> | ||
| )} | ||
| /> | ||
| ); | ||
|
|
||
| expect(getByTestSubject('euiTimeZoneDisplay')).toHaveTextContent( | ||
| 'Helsinki' | ||
| ); | ||
| expect(getByTestSubject('customContent')).toBeInTheDocument(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Unrelated to the marked line]:
I noticed that the
prependon theEuiFieldTextis not linked to the input (code), meaning the input has no label (the same applies in other tabs).We don't have to fix it here if you prefer keeping it scoped, but maybe you could add it at some point where it fits in while working on
EuiSuperDatePicker?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch, if I don't do it here, I'll make sure to do it while working on
EuiSuperDatePickeras you suggestThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do this in a separate PR 🫡