@@ -103,7 +103,7 @@ class InputSpinner extends Component {
103103 * @private
104104 */
105105 _setStateMin ( callback = null ) {
106- return this . setState ( { value : this . state . min } , callback ) ;
106+ return this . setState ( { value : "" } , callback ) ;
107107 }
108108
109109 /**
@@ -115,11 +115,60 @@ class InputSpinner extends Component {
115115 return this . setState ( { value : this . state . max } , callback ) ;
116116 }
117117
118+ /**
119+ * Clear min timer
120+ * @private
121+ */
122+ _clearMinTimer ( ) {
123+ clearTimeout ( this . maxTimer ) ;
124+ this . maxTimer = null ;
125+ }
126+
127+ /**
128+ * Clear max timer
129+ * @private
130+ */
131+ _clearMaxTimer ( ) {
132+ clearTimeout ( this . minTimer ) ;
133+ this . minTimer = null ;
134+ }
135+
136+ /**
137+ * Clear increase timer
138+ * @private
139+ */
140+ _clearIncreaseTimer ( ) {
141+ clearTimeout ( this . increaseTimer ) ;
142+ this . increaseTimer = null ;
143+ }
144+
145+ /**
146+ * Clear decrease timer
147+ * @private
148+ */
149+ _clearDecreaseTimer ( ) {
150+ clearTimeout ( this . decreaseTimer ) ;
151+ this . decreaseTimer = null ;
152+ }
153+
154+ /**
155+ * Clear all timers
156+ * @private
157+ */
158+ clearTimers ( ) {
159+ this . _clearIncreaseTimer ( ) ;
160+ this . _clearDecreaseTimer ( ) ;
161+ this . _clearMaxTimer ( ) ;
162+ this . _clearMinTimer ( ) ;
163+ }
164+
118165 /**
119166 * On value change
120167 * @param value
121168 */
122169 async onChange ( value ) {
170+ this . clearTimers ( ) ;
171+
123172 let num = value ;
124173 let parsedNum = value ;
125174 if ( isEmpty ( value ) ) {
@@ -140,14 +189,18 @@ class InputSpinner extends Component {
140189 if ( ! this . minReached ( num ) ) {
141190 if ( this . maxReached ( num ) ) {
142191 parsedNum = this . state . max ;
143- this . maxTimer = this . _debounceSetMax ( ) ;
192+ if ( ! isEmpty ( value ) ) {
193+ this . maxTimer = this . _debounceSetMax ( ) ;
194+ }
144195 if ( this . props . onMax ) {
145196 this . props . onMax ( this . state . max ) ;
146197 }
147198 }
148199 } else {
149200 parsedNum = this . state . min ;
150- this . minTimer = this . _debounceSetMin ( ) ;
201+ if ( ! isEmpty ( value ) ) {
202+ this . minTimer = this . _debounceSetMin ( ) ;
203+ }
151204 if ( this . props . onMin ) {
152205 this . props . onMin ( this . state . min ) ;
153206 }
@@ -163,10 +216,6 @@ class InputSpinner extends Component {
163216 }
164217 }
165218 if ( ! isEmpty ( value ) ) {
166- if ( parsedNum === num ) {
167- clearTimeout ( this . minTimer ) ;
168- clearTimeout ( this . maxTimer ) ;
169- }
170219 this . setState ( { value : num } ) ;
171220 } else {
172221 this . setState ( { value : value } ) ;
@@ -320,17 +369,6 @@ class InputSpinner extends Component {
320369 ) ;
321370 }
322371
323- clearTimers ( ) {
324- if ( this . increaseTimer ) {
325- clearTimeout ( this . increaseTimer ) ;
326- this . increaseTimer = null ;
327- }
328- if ( this . decreaseTimer ) {
329- clearTimeout ( this . decreaseTimer ) ;
330- this . decreaseTimer = null ;
331- }
332- }
333-
334372 /**
335373 * Get time to wait before increase/decrease on long press
336374 * @returns {number }
0 commit comments