From f5a3e2374b169cd6c0b46a7084eb5085648d6332 Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Thu, 12 Mar 2020 12:16:12 +0530 Subject: [PATCH 1/9] added enter key functionality --- CHANGELOG.md | 1 + .../__snapshots__/super_date_picker.test.js.snap | 1 + .../date_picker/super_date_picker/super_date_picker.js | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c55b85bcab9..9299e6cbe3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [`master`](https://github.com/elastic/eui/tree/master) +- Added `Enter` key press functionality to `EuiSuperDatePicker` ([#3043](https://github.com/elastic/eui/pull/3043)) - Exported `dateFormatAliases` as a part of the public API ([#3043](https://github.com/elastic/eui/pull/3043)) - Exported `EuiTextProps` type definition ([#3039](https://github.com/elastic/eui/pull/3039)) - Removed `role` attribute from `EuiImage`([#3036](https://github.com/elastic/eui/pull/3036)) diff --git a/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap b/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap index 391b5637789..eeaaddf75d5 100644 --- a/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap +++ b/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap @@ -4,6 +4,7 @@ exports[`EuiSuperDatePicker is rendered 1`] = ` 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 5ad5c5fe5c6..7f99e8ec389 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 @@ -312,6 +312,7 @@ export class EuiSuperDatePicker extends Component { isCustom startDateControl={
} endDateControl={
} + onKeyPress={this.handleKeyPress} readOnly> {prettyInterval(this.props.isPaused, this.props.refreshInterval)} @@ -412,6 +413,12 @@ export class EuiSuperDatePicker extends Component { } }; + handleKeyPress = event => { + if (event.key === 'Enter') { + this.handleClickUpdateButton(); + } + }; + renderUpdateButton = () => { if (!this.props.showUpdateButton || this.props.isAutoRefreshOnly) { return; @@ -461,6 +468,7 @@ export class EuiSuperDatePicker extends Component { Date: Thu, 12 Mar 2020 12:18:15 +0530 Subject: [PATCH 2/9] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9299e6cbe3b..8905af768b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -- Added `Enter` key press functionality to `EuiSuperDatePicker` ([#3043](https://github.com/elastic/eui/pull/3043)) +- Added `Enter` key press functionality to `EuiSuperDatePicker` ([#3048](https://github.com/elastic/eui/pull/3048)) - Exported `dateFormatAliases` as a part of the public API ([#3043](https://github.com/elastic/eui/pull/3043)) - Exported `EuiTextProps` type definition ([#3039](https://github.com/elastic/eui/pull/3039)) - Removed `role` attribute from `EuiImage`([#3036](https://github.com/elastic/eui/pull/3036)) From 4338b18d028d6fc3e2a6870ed3436532870f048f Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Fri, 13 Mar 2020 02:06:01 +0530 Subject: [PATCH 3/9] added it more strictly --- .../quick_select_popover/quick_select.js | 8 ++++++-- .../quick_select_popover/refresh_interval.js | 8 ++++++-- .../date_picker/super_date_picker/super_date_picker.js | 9 --------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/quick_select.js b/src/components/date_picker/super_date_picker/quick_select_popover/quick_select.js index 082760bd7bc..7a76dc2e052 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/quick_select.js +++ b/src/components/date_picker/super_date_picker/quick_select_popover/quick_select.js @@ -57,6 +57,10 @@ export class EuiQuickSelect extends Component { }); }; + handelKeyDown = ({ key }) => { + if (key === 'Enter') this.applyQuickSelect(); + }; + applyQuickSelect = () => { const { timeTense, timeValue, timeUnits } = this.state; @@ -122,7 +126,7 @@ export class EuiQuickSelect extends Component { const legendId = this.generateId(); return ( -
+
@@ -257,7 +261,7 @@ export class EuiQuickSelect extends Component { />

-
+
); } } diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js index 469433436b1..216514c6c60 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js +++ b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js @@ -90,6 +90,10 @@ export class EuiRefreshInterval extends Component { ); }; + handelKeyDown = ({ key }) => { + if (key === 'Enter') this.toogleRefresh(); + }; + applyRefreshInterval = () => { if (this.state.value === '') { return; @@ -123,7 +127,7 @@ export class EuiRefreshInterval extends Component { } return ( -
+

-
+
); } } 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 7f99e8ec389..790e8fe6d77 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 @@ -312,7 +312,6 @@ export class EuiSuperDatePicker extends Component { isCustom startDateControl={
} endDateControl={
} - onKeyPress={this.handleKeyPress} readOnly> {prettyInterval(this.props.isPaused, this.props.refreshInterval)} @@ -413,12 +412,6 @@ export class EuiSuperDatePicker extends Component { } }; - handleKeyPress = event => { - if (event.key === 'Enter') { - this.handleClickUpdateButton(); - } - }; - renderUpdateButton = () => { if (!this.props.showUpdateButton || this.props.isAutoRefreshOnly) { return; @@ -468,7 +461,6 @@ export class EuiSuperDatePicker extends Component { - {this.renderUpdateButton()} ); From 2aa0e8cc030725c65cb909d6f78daa061f27320a Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Sat, 14 Mar 2020 02:00:19 +0530 Subject: [PATCH 4/9] restored fieldset , removed typos --- .../__snapshots__/super_date_picker.test.js.snap | 1 - .../__snapshots__/quick_select.test.js.snap | 8 ++++++-- .../quick_select_popover/quick_select.js | 7 ++++--- .../quick_select_popover/refresh_interval.js | 13 +++++++------ 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap b/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap index eeaaddf75d5..391b5637789 100644 --- a/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap +++ b/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap @@ -4,7 +4,6 @@ exports[`EuiSuperDatePicker is rendered 1`] = ` diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap b/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap index 5edeb5a2be3..a0a43ef1871 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap +++ b/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap @@ -1,7 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`EuiQuickSelect is rendered 1`] = ` -
+
+
{ + handleKeyDown = ({ key }) => { if (key === 'Enter') this.applyQuickSelect(); }; @@ -126,7 +126,8 @@ export class EuiQuickSelect extends Component { const legendId = this.generateId(); return ( -
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions +
@@ -261,7 +262,7 @@ export class EuiQuickSelect extends Component { />

-
+
); } } diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js index 216514c6c60..05ebe1b905e 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js +++ b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js @@ -90,8 +90,8 @@ export class EuiRefreshInterval extends Component { ); }; - handelKeyDown = ({ key }) => { - if (key === 'Enter') this.toogleRefresh(); + handleKeyDown = ({ key }) => { + if (key === 'Enter') this.applyRefreshInterval(); }; applyRefreshInterval = () => { @@ -110,7 +110,7 @@ export class EuiRefreshInterval extends Component { }); }; - toogleRefresh = () => { + toggleRefresh = () => { this.props.applyRefreshInterval({ refreshInterval: toMilliseconds(this.state.units, this.state.value), isPaused: !this.props.isPaused, @@ -127,7 +127,8 @@ export class EuiRefreshInterval extends Component { } return ( -
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions +
@@ -190,7 +191,7 @@ export class EuiRefreshInterval extends Component { />

-
+
); } } From a3fdaba165fb85fb67e8a4224f44584e7e7132a7 Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Sat, 14 Mar 2020 02:06:48 +0530 Subject: [PATCH 5/9] used role and updated snap --- .../__snapshots__/quick_select.test.js.snap | 2 ++ .../super_date_picker/quick_select_popover/quick_select.js | 3 +-- .../super_date_picker/quick_select_popover/refresh_interval.js | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap b/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap index a0a43ef1871..dce8845c678 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap +++ b/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap @@ -3,6 +3,7 @@ exports[`EuiQuickSelect is rendered 1`] = `
+
diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js index 05ebe1b905e..0d5064c6813 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js +++ b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js @@ -127,8 +127,7 @@ export class EuiRefreshInterval extends Component { } return ( - // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -
+
Date: Mon, 16 Mar 2020 23:42:20 +0530 Subject: [PATCH 6/9] updated functionality --- .../quick_select_popover/refresh_interval.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js index 0d5064c6813..3b49da7c065 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js +++ b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js @@ -90,8 +90,21 @@ export class EuiRefreshInterval extends Component { ); }; + startRefresh = () => { + const { value, units } = this.state; + const isValid = value === '' || value <= 0; + if (isValid) { + this.props.applyRefreshInterval({ + refreshInterval: toMilliseconds(units, value), + isPaused: false, + }); + } + }; + handleKeyDown = ({ key }) => { - if (key === 'Enter') this.applyRefreshInterval(); + if (key === 'Enter') { + this.startRefresh(); + } }; applyRefreshInterval = () => { From 6d9b9039cfec99f8472bc9829037dc69225f937c Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Tue, 17 Mar 2020 11:57:17 +0530 Subject: [PATCH 7/9] removed keydown from fieldset --- .../__snapshots__/quick_select.test.js.snap | 12 ++++-------- .../quick_select_popover/quick_select.js | 6 +++++- .../quick_select_popover/refresh_interval.js | 5 ++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap b/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap index dce8845c678..94280605f3f 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap +++ b/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap @@ -1,10 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`EuiQuickSelect is rendered 1`] = ` -
+
+
+
@@ -198,6 +198,7 @@ export class EuiQuickSelect extends Component { {tenseLabel => ( ( ( +
@@ -178,6 +180,7 @@ export class EuiRefreshInterval extends Component { iconType={this.props.isPaused ? 'play' : 'stop'} size="s" onClick={this.toggleRefresh} + onKeyDown={this.handleKeyDown} disabled={value === '' || value <= 0} data-test-subj="superDatePickerToggleRefreshButton" aria-describedby={`${refreshSelectionId} ${legendId}`}> From e3f477cdc4597b84ff247a9f29c1f77fb76efb5b Mon Sep 17 00:00:00 2001 From: Anish Aggarwal <43617894+anishagg17@users.noreply.github.com> Date: Tue, 17 Mar 2020 21:04:45 +0530 Subject: [PATCH 8/9] Update src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js Co-Authored-By: Chandler Prall --- .../super_date_picker/quick_select_popover/refresh_interval.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js index 920db6d11ee..f13f6fba5cb 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js +++ b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js @@ -92,7 +92,7 @@ export class EuiRefreshInterval extends Component { startRefresh = () => { const { value, units } = this.state; - const isValid = value === '' || value <= 0; + const isValid = value !== '' || value > 0; if (isValid) { this.props.applyRefreshInterval({ refreshInterval: toMilliseconds(units, value), From 26590e09ea950af1480cf25321de88a3e1ef2e19 Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Tue, 17 Mar 2020 21:15:12 +0530 Subject: [PATCH 9/9] removed uneccessary onKeyDown --- .../__snapshots__/quick_select.test.js.snap | 2 -- .../super_date_picker/quick_select_popover/quick_select.js | 1 - .../super_date_picker/quick_select_popover/refresh_interval.js | 1 - 3 files changed, 4 deletions(-) diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap b/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap index 94280605f3f..5edeb5a2be3 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap +++ b/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap @@ -94,7 +94,6 @@ exports[`EuiQuickSelect is rendered 1`] = ` className="euiQuickSelect__applyButton" disabled={false} onClick={[Function]} - onKeyDown={[Function]} size="s" >