vlad-ignatov/react-numeric-input

Infinite increasing if disable and readOnly input right after the click.

Opened this issue · 1 comments

    onMouseDown(dir: "up"|"down", callback?: Function): void
    {
        if (dir == 'down') {
            this.decrease(false, callback);
        }
        else if (dir == 'up') {
            this.increase(false, callback);
        }
    }

after click in increase call you set a looping increase call for a long press as I understood

        if (isNaN(this.state.value) || +this.state.value < _max) {
            this._timer = setTimeout(() => {
                this.increase(true);
            }, _recursive ? NumericInput.SPEED : NumericInput.DELAY);
        }

but sometimes in complex forms I have to get new data from API and there's a need to disable Field until getting a response. So if I set input props disable or readOnly to true right after click (which is pretty common I believe not only for my case) input doesn't stops interval and it starts to increasing value infinitely.

made a pull request
#113