From 011e30bbdc057988ef0f033710db114ba1b5c531 Mon Sep 17 00:00:00 2001 From: john <johnbarlas39@gmail.com> Date: Mon, 17 Apr 2017 19:22:46 +0300 Subject: [PATCH] correct toggling behavior when there is an error --- app/components/Dashboard/AddBook.jsx | 8 +++----- app/components/common/AbstractModal.jsx | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/components/Dashboard/AddBook.jsx b/app/components/Dashboard/AddBook.jsx index 6450107..bd6a4ff 100644 --- a/app/components/Dashboard/AddBook.jsx +++ b/app/components/Dashboard/AddBook.jsx @@ -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> ) diff --git a/app/components/common/AbstractModal.jsx b/app/components/common/AbstractModal.jsx index ad15dd0..795018b 100644 --- a/app/components/common/AbstractModal.jsx +++ b/app/components/common/AbstractModal.jsx @@ -8,10 +8,8 @@ export class BookBuilderModal extends React.Component { } performAction () { - const { successAction, toggle } = this.props - + const { successAction } = this.props successAction() - toggle() } renderHeader () { -- GitLab