Skip to content

Commit

Permalink
[Rollup Jobs] Added autofocus to cron editor (#86324)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuliacech authored Dec 19, 2020
1 parent 94b4945 commit f7ace5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ interface Props {
fieldToPreferredValueMap: FieldToValueMap;
frequency: Frequency;
}) => void;
autoFocus?: boolean;
}

type State = FieldToValueMap;
Expand Down Expand Up @@ -234,6 +235,7 @@ export class CronEditor extends Component<Props, State> {
fullWidth
>
<EuiSelect
autoFocus={this.props.autoFocus}
options={excludeBlockListedFrequencies(UNITS, frequencyBlockList)}
value={frequency}
onChange={(e: React.ChangeEvent<HTMLSelectElement>) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ export class StepLogistics extends Component {
hasMatchingIndices: PropTypes.bool.isRequired,
indexPatternAsyncErrors: PropTypes.array,
};
state = { cronFocus: false };

showAdvancedCron = () => {
this.setState({ cronFocus: true });
const { onFieldsChange } = this.props;

onFieldsChange({
Expand All @@ -55,6 +57,7 @@ export class StepLogistics extends Component {
};

hideAdvancedCron = () => {
this.setState({ cronFocus: true });
const { onFieldsChange, fields } = this.props;
const { simpleRollupCron } = fields;

Expand Down Expand Up @@ -156,6 +159,7 @@ export class StepLogistics extends Component {
fullWidth
>
<EuiFieldText
autoFocus={this.state.cronFocus}
value={rollupCron}
onChange={(e) => onFieldsChange({ rollupCron: e.target.value })}
isInvalid={Boolean(areStepErrorsVisible && errorRollupCron)}
Expand All @@ -181,6 +185,7 @@ export class StepLogistics extends Component {
return (
<Fragment>
<CronEditor
autoFocus={this.state.cronFocus}
fieldToPreferredValueMap={fieldToPreferredValueMap}
cronExpression={rollupCron}
frequency={cronFrequency}
Expand Down

0 comments on commit f7ace5e

Please sign in to comment.