Skip to content

feat(jsonforms-renderers): multi-select SearchSelect for array x-search fields - #111

Merged
ginaxu1 merged 6 commits into
mainfrom
feat/searchselect-multi-x-search
Oct 19, 2026
Merged

ginaxu1 merged 6 commits into
mainfrom
feat/searchselect-multi-x-search

Conversation

@ginaxu1

@ginaxu1 ginaxu1 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14

Pairs with OpenNSW/one-trade-artifacts#160 (NPQS Transit Countries as array of x-search objects).

Summary

Array fields whose items carry x-search render as one searchable multi-select with chips, instead of ArrayControl Add Item cards.

  • Multi mode is inferred from type: "array" (no separate flag).
  • Object items store [{ value, label }, …]; string items store a string array (chips resolve labels on mount).
  • schema.maxItems stops further picks in the UI; AJV remains the safety net for preloaded data.
  • dependsOn clears the whole selection when a previously set sibling changes.
  • Single-value SearchSelect (string/object) unchanged.

Release notes

Array fields whose items carry x-search now render as one searchable multi-select with chips, instead of Add Item cards. Items of type: "object" (with value and label) store [{ value, label }, …]; items of type: "string" store a string array.

Test plan

  • NPQS apply: Transit Countries searchable multi dropdown, no Add Item
  • Select multiple; chips; remove one; clear all
  • Importing / Consignee single SearchSelect still works
  • vitest run src/renderers/SearchSelectControl.test.tsx passes
  • maxItems cap blocks a further pick
  • String-array preload shows resolved chip labels
  • Playground search-select-multi fixture

@github-actions github-actions Bot added Package/jsonforms-renderers Changes to packages/jsonforms-renderers Type/New Feature New feature request labels Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dc7d1425-1370-4569-9154-7f2834b5c23f
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ginaxu1

ginaxu1 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Pairs with OpenNSW/one-trade-artifacts#160 (Transit Countries as array of x-search objects).

@ginaxu1

ginaxu1 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author
multiselect_transit_countries_npqs.mov

@sthanikan2000 sthanikan2000 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Link the issue. This implements #14 (open, "multi-select support for SearchSelectControl"). Please add Closes #14 to the description. #14 also leaves two questions open that this PR answers by choice: multi mode is inferred from type: "array" with no flag, and dependsOn clears the selection when the parent changes. Please say so in the docs.
  2. 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 items carry x-search now render as one searchable multi-select with chips, instead of Add Item cards. Items of type: "object" (with value and label) store [{ value, label }, …]; items of type: "string" store a string array. Please also change the title scope to feat(jsonforms-renderers): multi-select SearchSelect for array x-search fields.
  3. 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.
  4. Fixture and docs. There's no playground fixture and no docs, unlike #95, #101 and #114. Please add a search-select-multi fixture to dev/fixtures.ts, modelled on search-select-object (line 333). Use the existing countries service 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 in docs/search-select-modes.md.
  5. One test assertion can't fail. See the inline comment on SearchSelectControl.test.tsx:483.
  6. maxItems isn't enforced in the UI. With maxItems: 2 I 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 on SearchSelectControl.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.

Comment thread packages/jsonforms-renderers/src/renderers/SearchSelectControl.tsx Outdated
Comment thread packages/jsonforms-renderers/src/renderers/SearchSelectControl.tsx
Comment thread packages/jsonforms-renderers/src/renderers/SearchSelectControl.test.tsx Outdated
@ginaxu1 ginaxu1 changed the title feat(jsonforms): multi-select SearchSelect for array x-search fields feat(jsonforms-renderers): multi-select SearchSelect for array x-search fields Oct 16, 2026
@ginaxu1
ginaxu1 requested a review from sthanikan2000 October 16, 2026 12:17
@ginaxu1

ginaxu1 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review on e963111:

  1. Description now has Closes jsonforms-renderers: multi-select support for SearchSelectControl (array of searched values) #14, and docs cover array-inferred multi mode plus dependsOn clearing the selection.
  2. Title scope is jsonforms-renderers; release notes section added.
  3. String-array chips: label cache from onSelect, batched resolve on mount; preload test added.
  4. Playground search-select-multi fixture (object + string items) and docs/search-select-modes.md updated (including tester rank).
  5. Add Item assertion uses queryByRole(/Add Item/).
  6. maxItems enforced in onSelect / disabled options; test + docs.

Item 7 stays on #123.

ginaxu1 and others added 4 commits October 16, 2026 22:52
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>
@ginaxu1
ginaxu1 force-pushed the feat/searchselect-multi-x-search branch from e963111 to 8fc7b9f Compare October 16, 2026 17:22

@sthanikan2000 sthanikan2000 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/jsonforms-renderers/dev/fixtures.ts Outdated
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>
@ginaxu1
ginaxu1 requested a review from sthanikan2000 October 17, 2026 10:56

@sthanikan2000 sthanikan2000 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@ginaxu1
ginaxu1 force-pushed the feat/searchselect-multi-x-search branch from 1f6ab39 to e7a96ed Compare October 19, 2026 05:42
@ginaxu1
ginaxu1 requested a review from sthanikan2000 October 19, 2026 05:45

@sthanikan2000 sthanikan2000 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ginaxu1
ginaxu1 merged commit b81fd48 into main Oct 19, 2026
5 checks passed
@ginaxu1
ginaxu1 deleted the feat/searchselect-multi-x-search branch October 19, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Package/jsonforms-renderers Changes to packages/jsonforms-renderers Type/New Feature New feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jsonforms-renderers: multi-select support for SearchSelectControl (array of searched values)

2 participants