Skip to content

Commit

Permalink
focus on start button after finishing current set for ease of use
Browse files Browse the repository at this point in the history
  • Loading branch information
KS-20 committed Jul 28, 2021
1 parent c1fa3ab commit e541e76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class App extends React.Component {
constructor(props) {
super(props);
this.state = { numToRecall: '12345', isInputMode: true };
this.startButton = React.createRef();
}

focusStartButton = () => {
this.startButton.current.focus();
}

componentDidMount() {
Expand Down Expand Up @@ -81,7 +86,9 @@ class App extends React.Component {
return (
<>
{mainDisplay}
<button type="button" autoFocus onClick={() => this.props.appEngine.startPracticeSet()}>start practice </button>
<button type="button" autoFocus onClick={() => this.props.appEngine.startPracticeSet() }
ref={this.startButton}>
start practice </button>
<p>length of number:</p>
<InputForm onChange={this.setNumLengthField} defaultValue={this.state.defaultNumSize} />
<p>Number of reps:</p>
Expand Down
6 changes: 5 additions & 1 deletion src/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class AppEngine {
var msg = "succeeded in "+this.currentSetRecord.getNumOfSuccessfulExercises()+" out of "+
this.currentSetRecord.getNumOfExercises();
this.guiController.setNumToRecall(msg);
this.guiController.focusStartButton();
}

return false;
Expand Down Expand Up @@ -196,14 +197,17 @@ class ReactGui {

}


activateDisplayMode() {
}

setNumToRecall(numToRecall) {
var stateToSet = { numToRecall: numToRecall, isInputMode: false };
this.appComponent.setState(stateToSet)
}

focusStartButton() {
this.appComponent.focusStartButton();
}
}

var appEngine = new AppEngine(new ReactGui());
Expand Down

0 comments on commit e541e76

Please sign in to comment.