-
Notifications
You must be signed in to change notification settings - Fork 863
[EuiSuperDatePicker] Support onFocus (#4924) #6320
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
Changes from 1 commit
12c045e
feb1649
b3aad72
0fec4de
52717c0
ffb6e14
71e6086
87d75db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import React, { Component, FunctionComponent } from 'react'; | ||
| import React, { Component, FocusEventHandler, FunctionComponent } from 'react'; | ||
| import classNames from 'classnames'; | ||
| import moment, { LocaleSpecifier } from 'moment'; // eslint-disable-line import/named | ||
| import dateMath from '@elastic/datemath'; | ||
|
|
@@ -87,6 +87,11 @@ export type EuiSuperDatePickerProps = CommonProps & { | |
| */ | ||
| locale?: LocaleSpecifier; | ||
|
|
||
| /** | ||
| * Triggered whenever the EuiSuperDatePicker is focused | ||
| */ | ||
| onFocus?: FocusEventHandler<HTMLDivElement>; | ||
|
|
||
| /** | ||
| * Callback for when the refresh interval is fired. | ||
| * EuiSuperDatePicker will only manage a refresh interval timer when onRefresh callback is supplied | ||
|
|
@@ -533,6 +538,7 @@ export class EuiSuperDatePickerInternal extends Component< | |
| isDisabled, | ||
| isPaused, | ||
| onRefreshChange, | ||
| onFocus, | ||
| recentlyUsedRanges, | ||
| refreshInterval, | ||
| showUpdateButton, | ||
|
|
@@ -547,6 +553,15 @@ export class EuiSuperDatePickerInternal extends Component< | |
| // Force reduction in width if showing quick select only | ||
| const width = isQuickSelectOnly ? 'auto' : _width; | ||
|
|
||
| const handleInputActivity = ( | ||
| event: | ||
| | React.KeyboardEvent<HTMLInputElement> | ||
| | React.MouseEvent<HTMLInputElement> | ||
| | any | ||
| ) => { | ||
| if (onFocus) onFocus(event); | ||
| }; | ||
|
|
||
| const autoRefreshAppend: EuiFormControlLayoutProps['append'] = !isPaused ? ( | ||
| <EuiAutoRefreshButton | ||
| className="euiFormControlLayout__append" | ||
|
|
@@ -612,6 +627,8 @@ export class EuiSuperDatePickerInternal extends Component< | |
| compressed={compressed} | ||
| isDisabled={isDisabled} | ||
| prepend={quickSelect} | ||
| onClick={handleInputActivity} | ||
| onKeyUp={handleInputActivity} | ||
|
||
| append={autoRefreshAppend} | ||
| data-test-subj={dataTestSubj} | ||
| > | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - Added onFocus callback on EuiSuperDatePicker | ||
UzairNoman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.