Scope through a property whose name ends in "then" or "else" binds the control to the wrong data path
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript
- Ambito
- backend-api-design, frontend
Direzione di ricerca
Inizia da packages/core/src/util/path.ts, dove l’issue identifica le espressioni regolari in toDataPath come causa del percorso errato. Esamina i test esistenti per la conversione dei percorsi e aggiungi copertura per le proprietà chiamate then, else o something_else, insieme ai segmenti composti da parole chiave intere. Il lavoro è completato quando i segmenti delle proprietà vengono mantenuti mentre i segmenti delle parole chiave dello schema continuano a essere rimossi, così che il percorso segnalato diventi something_else.name.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
toDataPathSegments strips then/ and else/ (and anyOf/N/ etc.) anywhere in the scope string, not only as whole path segments. So a scope that goes through a property named then, else, something_else, strengthen, ... is turned into a wrong data path:
import { toDataPath } from "@jsonforms/core";
toDataPath("#/properties/something_else/properties/name"); // "something_properties"
toDataPath("#/properties/then/properties/name"); // "properties"
toDataPath("#/properties/strengthen/properties/x"); // "strengproperties"
In a form the control shows nothing and typing writes to a new top-level key. With the React vanilla renderers, data { something_else: { name: "Bob" } } shows an empty input, and typing "Alice" produces
{"something_else":{"name":"Bob"},"something_properties":"Alice"}
Rules whose condition scope goes through such a property read the wrong value too.
Expected behavior
toDataPath("#/properties/something_else/properties/name") is "something_else.name", the input shows "Bob", and typing gives {"something_else":{"name":"Alice"}}. Only whole then/else segments (as in #/then/properties/x) should be dropped.
Steps to reproduce the issue
import { JsonForms } from "@jsonforms/react";
import { vanillaRenderers, vanillaCells } from "@jsonforms/vanilla-renderers";
const schema = {
type: "object",
properties: {
something_else: { type: "object", properties: { name: { type: "string" } } },
},
};
const uischema = {
type: "VerticalLayout",
elements: [{ type: "Control", scope: "#/properties/something_else/properties/name" }],
};
<JsonForms
schema={schema}
uischema={uischema}
data={{ something_else: { name: "Bob" } }}
renderers={vanillaRenderers}
cells={vanillaCells}
onChange={({ data }) => console.log(JSON.stringify(data))}
/>;
- Render the form: the input is empty instead of "Bob".
- Type "Alice":
onChangelogs{"something_else":{"name":"Bob"},"something_properties":"Alice"}.
With a property named name2 instead, the same form works.
Screenshots
No response
Which Version of JSON Forms are you using?
v3.8.0 (also master 942b76f)
Package
Core
Additional context
The regexes in packages/core/src/util/path.ts are /(anyOf|allOf|oneOf)\/[\d]+\//g and /(then|else)\//g. They match inside a segment, and they also match a segment that is a property name, so the scope would need to be split into segments first and then/else/anyOf/N dropped only where a keyword is expected (not right after properties).
Credit: https://ucsbplse.github.io/
- Lingua principale
- TypeScript
- Stelle
- 2.8k
- Fork
- 423
- Merge medio
- 5g 16h
- PR unite (30g)
- 9
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di eclipsesource/jsonforms
-
Add "append" and "prepend" slots for vue-vuetify extended renderersForse già presa @simeyc l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eclipsesource/jsonforms#2668 ·
I maintainer di solito rispondono entro 1 giorno
-
angular material
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
eclipsesource/jsonforms#2662 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
core
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eclipsesource/jsonforms#2570 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 50/100
eclipsesource/jsonforms#2651 ·
I maintainer di solito rispondono entro 1 giorno
-
angular: propagate the enabled state to detail renderers instead of modifying their UI schemaApertaangular material
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
eclipsesource/jsonforms#2630 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di eclipsesource/jsonforms
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
README の通知条件を実際の判定処理に合わせるForse già presa @unhappychoice l’ha presa oggi. Apertafactory:in-progress priority:medium
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
unhappychoice/oss-issue-opener#395 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug Website
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
OWASP/OWASP-Hunting#88 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno