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

Fixed console error in EuiDatePopoverContent #3254

Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Fixed the `img` element in `EuiIcon` using custom SVGs to have an `alt` attribute with an empty string, rather than no `alt` attribute at all ([#3245](https://github.com/elastic/eui/pull/3245))
- Added overflows to EuiDataGrid toolbar dropdowns when there are many columns ([#3238](https://github.com/elastic/eui/pull/3238))
- Fixed `EuiIcon`'s icon `type` definition to allow custom React components ([#3252](https://github.com/elastic/eui/pull/3252))
- Fixed `initialSelectedTab` properties used in `EuiDatePopoverContent` ([#3254](https://github.com/elastic/eui/pull/3254))

## [`22.3.0`](https://github.com/elastic/eui/tree/v22.3.0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,75 +37,76 @@ export function EuiDatePopoverContent({

const ariaLabel = `${position === 'start' ? 'Start' : 'End'} date:`;

const renderTabs = () => {
return [
{
id: DATE_MODES.ABSOLUTE,
name: 'Absolute',
content: (
<EuiAbsoluteTab
dateFormat={dateFormat}
timeFormat={timeFormat}
locale={locale}
value={value}
onChange={onChange}
roundUp={roundUp}
position={position}
/>
),
'data-test-subj': 'superDatePickerAbsoluteTab',
'aria-label': `${ariaLabel} Absolute`,
},
{
id: DATE_MODES.RELATIVE,
name: 'Relative',
content: (
<EuiRelativeTab
dateFormat={dateFormat}
locale={locale}
value={toAbsoluteString(value, roundUp)}
onChange={onChange}
roundUp={roundUp}
position={position}
/>
),
'data-test-subj': 'superDatePickerRelativeTab',
'aria-label': `${ariaLabel} Relative`,
},
{
id: DATE_MODES.NOW,
name: 'Now',
content: (
<EuiText
const renderTabs = [
{
id: DATE_MODES.ABSOLUTE,
name: 'Absolute',
content: (
<EuiAbsoluteTab
dateFormat={dateFormat}
timeFormat={timeFormat}
locale={locale}
value={value}
onChange={onChange}
roundUp={roundUp}
position={position}
/>
),
'data-test-subj': 'superDatePickerAbsoluteTab',
'aria-label': `${ariaLabel} Absolute`,
},
{
id: DATE_MODES.RELATIVE,
name: 'Relative',
content: (
<EuiRelativeTab
dateFormat={dateFormat}
locale={locale}
value={toAbsoluteString(value, roundUp)}
onChange={onChange}
roundUp={roundUp}
position={position}
/>
),
'data-test-subj': 'superDatePickerRelativeTab',
'aria-label': `${ariaLabel} Relative`,
},
{
id: DATE_MODES.NOW,
name: 'Now',
content: (
<EuiText
size="s"
color="subdued"
className="euiDatePopoverContent__padded--large">
<p>
Setting the time to &quot;now&quot; means that on every refresh this
time will be set to the time of the refresh.
</p>
<EuiButton
data-test-subj="superDatePickerNowButton"
onClick={() => onChange('now')}
fullWidth
size="s"
color="subdued"
className="euiDatePopoverContent__padded--large">
<p>
Setting the time to &quot;now&quot; means that on every refresh
this time will be set to the time of the refresh.
</p>
<EuiButton
data-test-subj="superDatePickerNowButton"
onClick={() => onChange('now')}
fullWidth
size="s"
fill>
Set {position} date and time to now
</EuiButton>
</EuiText>
),
'data-test-subj': 'superDatePickerNowTab',
'aria-label': `${ariaLabel} Now`,
},
];
};
fill>
Set {position} date and time to now
</EuiButton>
</EuiText>
),
'data-test-subj': 'superDatePickerNowTab',
'aria-label': `${ariaLabel} Now`,
},
];

const initialSelectedTab = () =>
renderTabs.filter(tabs => tabs.id === getDateMode(value))[0];

return (
<EuiTabbedContent
className="euiDatePopoverContent"
tabs={renderTabs()}
tabs={renderTabs}
autoFocus="selected"
initialSelectedTab={{ id: getDateMode(value) }}
initialSelectedTab={initialSelectedTab()}
onTabClick={onTabClick}
size="s"
expand
Expand Down