CarlosNZ / json-edit-react

React component for editing/viewing JSON/object data
https://carlosnz.github.io/json-edit-react/
MIT License
183 stars 18 forks source link

Bug report: [Enter] key on a boolean value does not trigger setData #97

Closed nathanmmiller closed 4 months ago

nathanmmiller commented 4 months ago

Describe the bug If you have a boolean value, and you double click it, then toggle the checkbox, then hit your keyboard's [Enter] key, setData is not called with the updated value.

Expected behavior I would expect setData to be called with the updated value, as happens for text or numbers.

Online demo I cannot access code sandbox but here is code that demonstrates the issue:

const Repro: React.FunctionComponent = () => {
    const [data, setData] = React.useState({ a: true });

    return (
        <div>
            <JsonEditor data={data} setData={setData} />
            Text Representation of Data: {JSON.stringify(data)}
        </div>
    );
};

Simply double click "true", uncheck the checkbox, and then hit the [Enter] key on your keyboard and you will see the "Text Representation of Data" does not change as expected.

CarlosNZ commented 4 months ago

Thanks for bringing this to my attention, will fix ASAP.

CarlosNZ commented 4 months ago

Okay, this is fixed now in v1.15.2

You should also be able to toggle the checkbox on and off with the space bar. :)

Thanks again for spotting it -- good catch 👍

nathanmmiller commented 3 months ago

Thanks for the quick fix!