diff options
author | afc163 <afc163@gmail.com> | 2017-02-20 16:31:54 +0800 |
---|---|---|
committer | afc163 <afc163@gmail.com> | 2017-02-20 16:31:54 +0800 |
commit | 71c3a19635d989f1ed99119bf230856d9faeef21 (patch) | |
tree | a27a828296830ecfdf709739d0cbc6e17357dde8 /src/TimePicker.jsx | |
parent | aa6d9b9f0867e1697a457c69e6df2bf8d0916e0a (diff) | |
download | time-picker-71c3a19635d989f1ed99119bf230856d9faeef21.tar.gz time-picker-71c3a19635d989f1ed99119bf230856d9faeef21.tar.zst time-picker-71c3a19635d989f1ed99119bf230856d9faeef21.zip |
Fix controlled open
Diffstat (limited to 'src/TimePicker.jsx')
-rw-r--r-- | src/TimePicker.jsx | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx index 4d7d4d6..e9d6d15 100644 --- a/src/TimePicker.jsx +++ b/src/TimePicker.jsx | |||
@@ -169,19 +169,16 @@ const Picker = React.createClass({ | |||
169 | ); | 169 | ); |
170 | }, | 170 | }, |
171 | 171 | ||
172 | setOpen(open, callback) { | 172 | setOpen(open) { |
173 | const { onOpen, onClose } = this.props; | 173 | const { onOpen, onClose } = this.props; |
174 | if (this.state.open !== open) { | 174 | if (this.state.open !== open) { |
175 | this.setState({ | 175 | if (!('open' in this.props)) { |
176 | open, | 176 | this.setState({ open }); |
177 | }, callback); | 177 | } |
178 | const event = { | ||
179 | open, | ||
180 | }; | ||
181 | if (open) { | 178 | if (open) { |
182 | onOpen(event); | 179 | onOpen({ open }); |
183 | } else { | 180 | } else { |
184 | onClose(event); | 181 | onClose({ open }); |
185 | } | 182 | } |
186 | } | 183 | } |
187 | }, | 184 | }, |