react-numeric icon indicating copy to clipboard operation
react-numeric copied to clipboard

Ctr+a and delete can not fire change event

Open namnguyen2091 opened this issue 4 years ago • 1 comments

When I ctr+a and press delete button, sometimes I see it can not fire change event, please let me know how to fix this.

namnguyen2091 avatar Mar 14 '20 01:03 namnguyen2091

I see your code is too complicated to manage, I rewrite this very simple but it resolves my problem. I think this problem may be happen in getValue function, nothing return when this.autonumeric is can not find.

import React from "react";
import AutoNumeric from "autonumeric";

export class Numeric extends React.Component {
    constructor(props) {
        super(props);
    }

    componentDidMount() {
        this.numeric = new AutoNumeric(this.input, {
            currencySymbol : '$',
            onInvalidPaste: 'truncate'
        });
    }

    componentWillUnmount() {
        this.numeric.remove();
    }

    render() {
        return (
            <input
                type="text"
                ref={ref => this.input = ref}
                className="bp3-input"
                onChange={e => console.log(e.target.value)}
            />
        );
    }
}

Numeric.defaultProps = {
    type: "text",
    outputFormat: "number",
    preDefined: {},
    className: "asdf",
};

namnguyen2091 avatar Mar 14 '20 02:03 namnguyen2091