Repository navigation
feat(jsonforms-renderers): multi-select SearchSelect for array x-search fields - #111
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Pairs with OpenNSW/one-trade-artifacts#160 (Transit Countries as array of x-search objects). |
multiselect_transit_countries_npqs.mov |
3ecb875 to
f4cf06e
Compare
sthanikan2000
left a comment
There was a problem hiding this comment.
Thanks @ginaxu1, the object-item case works well: I ran the branch, and chips show the stored labels, de-duplication works, and the single-value controls are unchanged. I'm requesting changes for items 1–6. Item 7 is a follow-up and not for this PR.
Needs fixing before merge
- Link the issue. This implements #14 (open, "multi-select support for SearchSelectControl"). Please add
Closes #14to the description. #14 also leaves two questions open that this PR answers by choice: multi mode is inferred fromtype: "array"with no flag, anddependsOnclears the selection when the parent changes. Please say so in the docs. - Release notes and title. The description doesn't use the PR template, so the release script has no consumer text, and this adds a data-shape contract. Suggested: Array fields whose
itemscarryx-searchnow render as one searchable multi-select with chips, instead of Add Item cards. Items oftype: "object"(withvalueandlabel) store[{ value, label }, …]; items oftype: "string"store a string array. Please also change the title scope tofeat(jsonforms-renderers): multi-select SearchSelect for array x-search fields. - String items show raw ids as chips. See the inline comment on
SearchSelectControl.tsx:227. Either fix it or restrict the tester to object items and say so. - Fixture and docs. There's no playground fixture and no docs, unlike #95, #101 and #114. Please add a
search-select-multifixture todev/fixtures.ts, modelled onsearch-select-object(line 333). Use the existingcountriesservice and preload a couple of values. Include one object-items field and, once item 3 is fixed, one string-items field. Please also document the array shapes and the stored data indocs/search-select-modes.md. - One test assertion can't fail. See the inline comment on
SearchSelectControl.test.tsx:483. maxItemsisn't enforced in the UI. WithmaxItems: 2I could pick three options and get['IN','SG','LK'], with the form showing "must NOT have more than 2 items". Please stop the extra pick, as described in the inline comment onSearchSelectControl.tsx:408, and add a test.
Follow-up, not for this PR
7. Multi-select for static enum/oneOf arrays on SelectControl should store the same shapes, with multi mode, the item shape and minItems/maxItems in the schema, and only presentation in the uiSchema. Tracked in #123.
|
Addressed the review on e963111:
Item 7 stays on #123. |
Array-of-object fields with x-search on items (e.g. NPQS Transit Countries) were falling through to ArrayControl Add Item cards. Match them at a higher rank and toggle selections in one searchable dropdown so single string/object SearchSelect behaviour stays unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Drop the closed-field comma summary so Transit Countries does not duplicate chips and text when the dropdown is closed. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve string-array chip labels on mount, enforce schema.maxItems in the UI, fix the Add Item assertion, and add a playground fixture plus docs for array shapes and tester rank. Co-authored-by: Cursor <cursoragent@cursor.com>
e963111 to
8fc7b9f
Compare
sthanikan2000
left a comment
There was a problem hiding this comment.
Thanks @ginaxu1, re-checked on 8fc7b9f. All six items are addressed, and I ran each one: string chips show labels after a pick and on preload (one resolve call per id, and a failing resolve keeps the raw id), maxItems stops the extra pick and disables the remaining option, and the Add Item assertion now fails if ArrayControl renders. I also broke each of the three new tests on purpose, and each one fails as it should. 600 tests pass, type-check is clean.
One fixture nit is left, inline on dev/fixtures.ts.
The playground countries service has no nz, so the string-items field showed a raw id chip. Preload au and lk instead. Co-authored-by: Cursor <cursoragent@cursor.com>
sthanikan2000
left a comment
There was a problem hiding this comment.
Thanks @ginaxu1, re-checked on 1f6ab39. The fixture is fixed: I rendered it with the real dev service and all four chips show names. The debounce flush in ArrayControl.required.test.tsx is justified; without it I reproduced window is not defined and a non-zero exit. One more instance of the same flake is left, in the new string-array test (inline). It's a small fix, and then this looks good to me.
…l test cleanup Co-authored-by: Cursor <cursoragent@cursor.com>
1f6ab39 to
e7a96ed
Compare
Closes #14
Pairs with OpenNSW/one-trade-artifacts#160 (NPQS Transit Countries as
arrayofx-searchobjects).Summary
Array fields whose
itemscarryx-searchrender as one searchable multi-select with chips, instead of ArrayControl Add Item cards.type: "array"(no separate flag).[{ value, label }, …]; string items store a string array (chips resolve labels on mount).schema.maxItemsstops further picks in the UI; AJV remains the safety net for preloaded data.dependsOnclears the whole selection when a previously set sibling changes.Release notes
Array fields whose
itemscarryx-searchnow render as one searchable multi-select with chips, instead of Add Item cards. Items oftype: "object"(withvalueandlabel) store[{ value, label }, …]; items oftype: "string"store a string array.Test plan
vitest run src/renderers/SearchSelectControl.test.tsxpassessearch-select-multifixture