Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is "dot-separated" path safe? #1849

Closed
mirismaili opened this issue Dec 11, 2021 · 3 comments
Closed

Is "dot-separated" path safe? #1849

mirismaili opened this issue Dec 11, 2021 · 3 comments

Comments

@mirismaili
Copy link
Contributor

mirismaili commented Dec 11, 2021

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:

export const composeWithUi = (scopableUi: Scopable, path: string): string => {
const segments = toDataPathSegments(scopableUi.scope);
if (isEmpty(segments) && path === undefined) {
return '';
}
return isEmpty(segments) ? path : compose(path, segments.join('.'));
};

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

@sdirix
Copy link
Member

sdirix commented Dec 13, 2021

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.

@mirismaili
Copy link
Contributor Author

Hi @sdirix,

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

mirismaili added a commit to mirismaili/jsonforms that referenced this issue Dec 21, 2021
… `string`) for react (in these packages: "core", "react" and "material-renderers")

eclipsesource#1849
eclipsesource#1831
mirismaili added a commit to mirismaili/jsonforms that referenced this issue Dec 23, 2021
… `string`) for react (in these packages: "core", "react" and "material-renderers")

eclipsesource#1849
eclipsesource#1831
mirismaili added a commit to mirismaili/jsonforms that referenced this issue Dec 23, 2021
… `string`) for react (in these packages: "core", "react" and "material-renderers")

eclipsesource#1849
eclipsesource#1831
mirismaili added a commit to sabzco/jsonforms that referenced this issue Dec 23, 2021
… `string`) for react (in these packages: "core", "react" and "material-renderers")

eclipsesource#1849
eclipsesource#1831
mirismaili added a commit to sabzco/jsonforms that referenced this issue Dec 29, 2021
… `string`) for react (in these packages: "core", "react" and "material-renderers")

eclipsesource#1849
eclipsesource#1831
mirismaili added a commit to sabzco/jsonforms that referenced this issue Jan 1, 2022
… `string`) for react (in these packages: "core", "react" and "material-renderers")

eclipsesource#1849
eclipsesource#1831
mirismaili added a commit to sabzco/jsonforms that referenced this issue Jan 12, 2022
… `string`) for react (in these packages: "core", "react" and "material-renderers")

eclipsesource#1849
eclipsesource#1831
@sdirix sdirix added this to the 3.x milestone Feb 11, 2022
@sdirix sdirix removed this from the 3.x milestone Jun 29, 2023
@sdirix
Copy link
Member

sdirix commented Jun 29, 2023

We settled on an improvement, documented it in #2153 and will start developing it soon. Therefore I'll close this issue as the follow up already exists.

@sdirix sdirix closed this as completed Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants