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

Unable to add list element #1948

Closed
agonzalezgaliana opened this issue May 30, 2022 · 2 comments · Fixed by #1957
Closed

Unable to add list element #1948

agonzalezgaliana opened this issue May 30, 2022 · 2 comments · Fixed by #1957
Assignees
Milestone

Comments

@agonzalezgaliana
Copy link

Describe the bug

The problem comes from here

Using @eclipse-emfcloud/theia-tree-editor and indirectly:

    "@jsonforms/core": "3.0.0-alpha.2",
    "@jsonforms/react": "3.0.0-alpha.2",
    "@jsonforms/vanilla-renderers": "3.0.0-alpha.2"

Basically, when providing

  • JSON schema
  • JSON data

to JSON forms, it shows a UI with a [+] button (which seems that should allow to add a new element to my list).

Actually, by clicking that button nothing happens:

  • No errors
  • No exceptions in the console
  • Corresponding method in the Tree Editor is not called

However, when we only provide

  • JSON data

to JSON forms, it shows a completely different UI.

In this UI, the add button actually triggers the corresponding listener in the Tree Editor.

Expected behavior

That by clicking the [+] button the listener methods are called and we can react on user action.

Steps to reproduce the issue

/

Screenshots

No response

In which browser are you experiencing the issue?

Firefox Version 99.0.1

Framework

Core, React

RendererSet

Vanilla

Additional context

The relevant schema snippet is the following:

               "import": {
			"$id": "#import",
			"title": "Import",
			"type": "object",
			"properties": {
				"eClass": {
					"const": "http://my_schema/1.0.0#//Import"
				},
				"document": {
					"type": "string"
				},
				"package": {
					"type": "string"
				},
				"prefix": {
					"type": "string"
				}
			},
			"additionalProperties": false,
			"required": ["document", "package", "prefix"]
		},
		"imports": {
			"$id": "#imports",
			"title": "Imports",
			"type": "object",
			"properties": {
				"eClass": {
					"const": "http://my_schema/1.0.0#//Imports"
				},
				"import": {
					"type": "array",
					"items": {
						"$ref": "#/definitions/import"
					}
				}
			},
			"additionalProperties": false,
			"required": ["import"]
		}

The data looks like the following:

{
	"import": [{
		"document": "Document1",
		"package": "Package1",
		"prefix": "Prefix"
	}]
}
eneufeld added a commit to eneufeld/jsonforms that referenced this issue Jun 20, 2022
The vanilla ArrayControl was wrapping the `addItem` in a function,
whereas the `addItem` function is already wrapped. So the `onClick`
can directly be bound to `addItem`.

Fixes eclipsesource#1948
eneufeld added a commit to eneufeld/jsonforms that referenced this issue Jun 20, 2022
The vanilla ArrayControl was wrapping the `addItem` in a function,
whereas the `addItem` function is already wrapped. So the `onClick`
can directly be bound to `addItem`. The wrong binding lead to the
add functionality not working.

Increase rank of the ArrayControl so that it behaves the same as
for the react material renderers.

Add example to demonstrate different selections of renderers based
on the existince of a const property in the schema.

Fixes eclipsesource#1948
@eneufeld
Copy link
Member

Hi @agonzalezgaliana ,
I looked into the issue. I can reproduce the different renderers being chosen.
I didn't adapt this but I fixed the add functionality in the array layout control case.

@sdirix sdirix added this to the 3.0 milestone Jun 20, 2022
eneufeld added a commit to eneufeld/jsonforms that referenced this issue Jun 20, 2022
The vanilla ArrayControl was wrapping the `addItem` in a function,
whereas the `addItem` function is already wrapped. So the `onClick`
can directly be bound to `addItem`. The wrong binding lead to the
add functionality not working.

Increase rank of the ArrayControl so that it behaves the same as
for the react material renderers.

Add example to demonstrate different selections of renderers based
on the existince of a const property in the schema.

Fix wrong selection of array layout if type is missing.

Fixes eclipsesource#1948
@eneufeld
Copy link
Member

Now I also fixed the wrong renderer selection ;-) .

sdirix pushed a commit that referenced this issue Jun 21, 2022
The vanilla ArrayControl was wrapping the `addItem` in a function,
whereas the `addItem` function is already wrapped. So the `onClick`
can directly be bound to `addItem`. The wrong binding lead to the
add functionality not working.

Increase rank of the ArrayControl so that it behaves the same as
for the react material renderers.

Add example to demonstrate different selections of renderers based
on the existince of a const property in the schema.

Fix wrong selection of array layout if type is missing.

Fixes #1948
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants