diff --git a/src/App.css b/src/App.css index 8422788..17ca5b4 100644 --- a/src/App.css +++ b/src/App.css @@ -16,7 +16,7 @@ border: none; border-bottom: solid; } -.App input[type="button"]{ +.App input[type="submit"]{ color: white; background: rgba(0,0,0,0.31); border: none; diff --git a/src/App.js b/src/App.js index f9635ac..8443720 100644 --- a/src/App.js +++ b/src/App.js @@ -12,38 +12,31 @@ class App extends Component { this.input.focus() } - handleKeyPress = e => { - const { showAnswer } = this.state; - if (e.key === 'Enter') { - if (!showAnswer && this.input.value.length === 0) return - this.toggleShowAnswer() - } - } - - toggleShowAnswer = () => { + toggleShowAnswer (evt) { + evt.preventDefault(); const { showAnswer } = this.state; - this.setState({showAnswer: !showAnswer}) + if (!showAnswer && !this.input.value) return; + this.setState({showAnswer: !showAnswer}); if (showAnswer) this.back.focus() } render() { const {showAnswer} = this.state; return ( -