Skip to content

Commit

Permalink
add focus
Browse files Browse the repository at this point in the history
  • Loading branch information
stefdelec committed Oct 17, 2019
1 parent 8731e92 commit 08836b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ const initialState = { value: '', timestamp: Date.now(), toggle: false };
class App extends Component {
constructor(props) {
super(props);
this.state =initialState;
this.state = initialState;
this.change = this.change.bind(this);
this.toggle = this.toggle.bind(this);
}

launchTimer = () => {
console.log('clearing')
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
this.setState(initialState);
console.log('reset')
setTimeout(() => {
document.getElementById('inputPassword').focus();
})
}, 30000)
}
change(event) {
Expand Down
9 changes: 5 additions & 4 deletions src/components/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import React, { Component } from 'react';

class Input extends Component {

componentDidMount(){}

render = () => {
const { change, value } = this.props;
return (
<div className="form-group">
<label htmlFor="inputPassword">Password</label>
<input autoFocus value={value} type="password" onChange={change} className="form-control" id="inputPassword" placeholder="Your Password" />
<div className="form-group mt-2">
<input
value={value}
type="password" onChange={change} className="form-control" id="inputPassword" placeholder="Your Password" />
</div>

)
Expand Down

0 comments on commit 08836b1

Please sign in to comment.