File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed
src/react-chayns-amountcontrol/component Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -139,16 +139,31 @@ export default class AmountControl extends PureComponent {
139139 } ;
140140
141141 changeAmount = ( amount ) => {
142- const { onChange, onInput } = this . props ;
142+ const {
143+ onChange,
144+ onInput,
145+ amount : oldAmount ,
146+ disableAdd,
147+ disableRemove,
148+ } = this . props ;
149+
150+ if ( onInput ) {
151+ onInput ( amount ) ;
152+ }
143153
144154 if ( onChange ) {
155+ if ( ( disableAdd && amount > oldAmount )
156+ || ( disableRemove && amount < oldAmount ) ) {
157+ this . setState ( {
158+ tempValue : oldAmount ,
159+ } ) ;
160+
161+ return ;
162+ }
163+
145164 onChange ( amount ) ;
146165 this . setInput ( false ) ;
147166 }
148-
149- if ( onInput ) {
150- onInput ( amount ) ;
151- }
152167 } ;
153168
154169 setInput = ( value ) => {
You can’t perform that action at this time.
0 commit comments