json-editor icon indicating copy to clipboard operation
json-editor copied to clipboard

enforce_const doesn't work with setValue

Open abakumovoleg opened this issue 1 year ago • 1 comments

General information

  • json-editor version: 2.15.1

Expected behavior

A control is initially created without any data but with 'enforce_const' flag to 'true'. The fields that have the 'constant' attribute in their scheme should be locked for editing. They should remain locked regardless of other user interactions.

Actual behavior

While the 'constant' fields behave as expected when the control is first created (they are locked for editing), they become editable once the method editor.setValue() is triggered programmatically, using any input JSON. This should not happen, they should remain locked for editing regardless of data input.

Steps to reproduce the behavior

  1. Create a control without startval with enforce_const:true. Verify that all fields with the constant sign in the schema are blocked for editing.
  2. Call the editor.setValue() method programmatically and pass any json.
  3. Note, all the fields which were blocked are now available for editing.

abakumovoleg avatar Jun 28 '24 17:06 abakumovoleg

We're looking into that ... I agree with your point when you set the correct value. But ... what should happen, when you set the wrong value (eg. const: 5, setValue(8))?

schmunk42 avatar Jul 12 '24 10:07 schmunk42