diff --git a/CHANGELOG.md b/CHANGELOG.md index 94d1d397fb2..52b875f4473 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `9.4.0`. +**Bug fixes** + +- Adds missing type and fixes closure-scope problem for `SuperDatePicker`'s `onRefresh` callback ([#1732](https://github.com/elastic/eui/pull/1732)) ## [`9.4.0`](https://github.com/elastic/eui/tree/v9.4.0) diff --git a/src/components/date_picker/index.d.ts b/src/components/date_picker/index.d.ts index e243a3d3ca4..7402ba53670 100644 --- a/src/components/date_picker/index.d.ts +++ b/src/components/date_picker/index.d.ts @@ -1,7 +1,9 @@ import React from 'react'; import { CommonProps } from '../common'; import { IconType } from '../icon'; -import _ReactDatePicker, { ReactDatePickerProps as _ReactDatePickerProps } from './react-datepicker'; +import _ReactDatePicker, { + ReactDatePickerProps as _ReactDatePickerProps, +} from './react-datepicker'; import { Moment } from 'moment'; declare module '@elastic/eui' { @@ -12,6 +14,12 @@ declare module '@elastic/eui' { isQuickSelection: boolean; } + interface OnRefreshProps { + start: string; + end: string; + refreshInterval: number; + } + interface OnRefreshChangeProps { isPaused: boolean; refreshInterval: number; @@ -63,6 +71,7 @@ declare module '@elastic/eui' { isPaused?: boolean; refreshInterval?: number; onTimeChange: (props: OnTimeChangeProps) => void; + onRefresh: (props: OnRefreshProps) => void; onRefreshChange?: (props: OnRefreshChangeProps) => void; commonlyUsedRanges?: EuiSuperDatePickerCommonRange[]; dateFormat?: string; diff --git a/src/components/date_picker/super_date_picker/super_date_picker.js b/src/components/date_picker/super_date_picker/super_date_picker.js index 99bdbd709b7..649a2a35852 100644 --- a/src/components/date_picker/super_date_picker/super_date_picker.js +++ b/src/components/date_picker/super_date_picker/super_date_picker.js @@ -257,9 +257,12 @@ export class EuiSuperDatePicker extends Component { } startInterval = (refreshInterval) => { - const { start, end, onRefresh } = this.props; + const { onRefresh } = this.props; if(onRefresh) { - const handler = () => onRefresh({ start, end, refreshInterval }); + const handler = () => { + const { start, end } = this.props; + onRefresh({ start, end, refreshInterval }); + }; this.asyncInterval = new AsyncInterval(handler, refreshInterval); } }