Skip to content
Snippets Groups Projects
Commit 011e30bb authored by john's avatar john
Browse files

correct toggling behavior when there is an error

parent df064f27
No related branches found
No related tags found
No related merge requests found
......@@ -20,20 +20,18 @@ export default class AddBook extends React.Component {
handleKeyOnInput (event) {
if (event.charCode !== 13) return
const { toggle } = this.props
this.onCreate()
toggle()
}
onCreate () {
const { create } = this.props
const { create, toggle } = this.props
const input = this.inputRef
const newTitle = input.value.trim()
if (newTitle.length === 0) return this.setState({ error: true })
create(newTitle)
toggle()
}
onInputChange () {
......@@ -64,7 +62,7 @@ export default class AddBook extends React.Component {
const { error } = this.state
const el = (
<div>
<div className='error' >
New book title cannot be empty
</div>
)
......
......@@ -8,10 +8,8 @@ export class BookBuilderModal extends React.Component {
}
performAction () {
const { successAction, toggle } = this.props
const { successAction } = this.props
successAction()
toggle()
}
renderHeader () {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment