jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

Is "dot-separated" path safe?

Open mirismaili opened this issue 2 years ago • 2 comments

Describe the bug

As you know there is a path prop that is passed to the renderer that indicates the location of data (that should be rendered by that renderer) in the root data object (e.g. 'foo.bar').

It's a dot-separated string:

https://github.com/eclipsesource/jsonforms/blob/81f1f19dac49b1864e712e9abbc5c5c6355a2b91/packages/core/src/util/path.ts#L82-L90

compose(path, segments.join('.'))

Is this safe? Then 'foo.bar' points to data.foo.bar or data['foo.bar']?

Expected behavior

The library should can distinguish between these paths. For example, using arrays (instead of strings):

path1 = ['foo', 'bar']
path2 = ['foo.bar']

Steps to reproduce the issue

  1. Go to Playground

  2. Set: JSON-Schema:

    {
      "type": "object",
      "properties": {
        "my.name": {
          "type": "string"
        }
      }
    }
    

    UI-Schema:

    false
    

    Data:

    {
      "my.name": "S. Mahdi",
      "my": {
        "name": "MirIsmaili"
      }
    }
    

As you can see in the playground, the synchronization process flows along with the green arrows (see below screenshot), but NOT along with the red arrows. (When you edit the form, data['my.name'] will be updated (only) and when you edit data.my.name in the editor (only), the form will be updated).

Screenshots

image

In which browser are you experiencing the issue?

Google Chrome v96.0.4664.93 (Official Build) (64-bit)

Framework

No response

RendererSet

No response

Additional context

No response

mirismaili avatar Dec 11 '21 11:12 mirismaili

Hi @mirismaili, thanks for the report. The issue is already reported and we're already working on a fix, see #1831. However the change is non trivial as using an array as a prop triggers rerenders by default in all bindings. Therefore we want to make sure that we don't introduce any regressions.

sdirix avatar Dec 13 '21 08:12 sdirix

Hi @sdirix,

OK. So I develop new features that I'm working on (additionalProperties and patternProperties), with this issue until this be resolved.

mirismaili avatar Dec 14 '21 13:12 mirismaili

We settled on an improvement, documented it in https://github.com/eclipsesource/jsonforms/issues/2153 and will start developing it soon. Therefore I'll close this issue as the follow up already exists.

sdirix avatar Jun 29 '23 11:06 sdirix