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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `21.1.0`.
- Added `Enter` key press functionality to `EuiSuperDatePicker` ([#3048](https://github.com/elastic/eui/pull/3048))

## [`21.1.0`](https://github.com/elastic/eui/tree/v21.1.0)

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 @@ -194,6 +198,7 @@ export class EuiQuickSelect extends Component {
{tenseLabel => (
<EuiSelect
compressed
onKeyDown={this.handleKeyDown}
aria-label={tenseLabel}
aria-describedby={`${timeSelectionId} ${legendId}`}
value={timeTense}
Expand All @@ -208,6 +213,7 @@ export class EuiQuickSelect extends Component {
{valueLabel => (
<EuiFieldNumber
compressed
onKeyDown={this.handleKeyDown}
aria-describedby={`${timeSelectionId} ${legendId}`}
aria-label={valueLabel}
value={timeValue}
Expand All @@ -221,6 +227,7 @@ export class EuiQuickSelect extends Component {
{unitLabel => (
<EuiSelect
compressed
onKeyDown={this.handleKeyDown}
aria-label={unitLabel}
aria-describedby={`${timeSelectionId} ${legendId}`}
value={timeUnits}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ 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.startRefresh();
}
};

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

toogleRefresh = () => {
toggleRefresh = () => {
this.props.applyRefreshInterval({
refreshInterval: toMilliseconds(this.state.units, this.state.value),
isPaused: !this.props.isPaused,
Expand Down Expand Up @@ -139,6 +156,7 @@ export class EuiRefreshInterval extends Component {
compressed
value={value}
onChange={this.onValueChange}
onKeyDown={this.handleKeyDown}
aria-label="Refresh interval value"
aria-describedby={`${refreshSelectionId} ${legendId}`}
data-test-subj="superDatePickerRefreshIntervalInput"
Expand All @@ -152,6 +170,7 @@ export class EuiRefreshInterval extends Component {
value={units}
options={refreshUnitsOptions}
onChange={this.onUnitsChange}
onKeyDown={this.handleKeyDown}
data-test-subj="superDatePickerRefreshIntervalUnitsSelect"
/>
</EuiFlexItem>
Expand All @@ -160,7 +179,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