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

added enter key functionality #3048

Merged
merged 13 commits into from
Mar 17, 2020
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added `Enter` key press functionality to `EuiSuperDatePicker` ([#3048](https://github.com/elastic/eui/pull/3048))
- Added props descriptions for `EuiComboBox` ([#3007](https://github.com/elastic/eui/pull/3007))
- 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))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiQuickSelect is rendered 1`] = `
<fieldset>
<fieldset
onKeyDown={[Function]}
role="presentation"
>
<EuiI18n
default="Quick select a time range"
token="euiQuickSelect.legendText"
Expand Down Expand Up @@ -127,7 +130,10 @@ exports[`EuiQuickSelect is rendered 1`] = `
`;

exports[`EuiQuickSelect prevQuickSelect 1`] = `
<fieldset>
<fieldset
onKeyDown={[Function]}
role="presentation"
>
<EuiI18n
default="Quick select a time range"
token="euiQuickSelect.legendText"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export class EuiQuickSelect extends Component {
});
};

handleKeyDown = ({ key }) => {
if (key === 'Enter') this.applyQuickSelect();
};

applyQuickSelect = () => {
const { timeTense, timeValue, timeUnits } = this.state;

Expand Down Expand Up @@ -122,7 +126,7 @@ export class EuiQuickSelect extends Component {
const legendId = this.generateId();

return (
<fieldset>
<fieldset role="presentation" onKeyDown={this.handleKeyDown}>
<EuiI18n
token="euiQuickSelect.legendText"
default="Quick select a time range">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export class EuiRefreshInterval extends Component {
);
};

handleKeyDown = ({ key }) => {
if (key === 'Enter') this.applyRefreshInterval();
};

applyRefreshInterval = () => {
if (this.state.value === '') {
return;
Expand All @@ -106,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,
Expand All @@ -123,7 +127,7 @@ export class EuiRefreshInterval extends Component {
}

return (
<fieldset>
<fieldset role="presentation" onKeyDown={this.handleKeyDown}>
<EuiTitle size="xxxs">
<legend id={legendId}>
<EuiI18n
Expand Down Expand Up @@ -160,7 +164,7 @@ export class EuiRefreshInterval extends Component {
className="euiRefreshInterval__startButton"
iconType={this.props.isPaused ? 'play' : 'stop'}
size="s"
onClick={this.toogleRefresh}
onClick={this.toggleRefresh}
disabled={value === '' || value <= 0}
data-test-subj="superDatePickerToggleRefreshButton"
aria-describedby={`${refreshSelectionId} ${legendId}`}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ export class EuiSuperDatePicker extends Component {
{this.renderDatePickerRange()}
</EuiFormControlLayout>
</EuiFlexItem>

{this.renderUpdateButton()}
</EuiFlexGroup>
);
Expand Down