Skip to content

Custom identifier combobox with allowCustomValue flag - #1508

Open
david-roper wants to merge 6 commits into
DouglasNeuroInformatics:mainfrom
david-roper:custom-identifier-combobox
Open

Custom identifier combobox with allowCustomValue flag#1508
david-roper wants to merge 6 commits into
DouglasNeuroInformatics:mainfrom
david-roper:custom-identifier-combobox

Conversation

@david-roper

Copy link
Copy Markdown
Collaborator

Suggest existing custom identifiers on the Start Session form

The identifier field for the CUSTOM_ID identification method was a free-text input, so a
clinician re-enrolling an existing subject had to remember and retype that subject's identifier
exactly, with a typo silently creating a second subject.

This turns that field into a combobox that suggests the custom identifiers already in use in the
current group, while still accepting a brand new identifier typed in full.

Changes

apps/web/src/routes/_app/session/start-session.tsx

  • Adds a loader that prefetches subjectsQueryOptions({ params: { groupId } }) into React Query,
    and a matching useSubjectsQuery in the component, per the repo's data-hook convention (loader
    and component share one key).
  • Derives customSubjectIds from that data: subjects with no personal info, with the group scope
    prefix stripped via removeSubjectIdScope.

apps/web/src/components/StartSessionForm/StartSessionForm.tsx

  • New required customSubjectIds: string[] prop.
  • The subjectId field goes from variant: 'input' to variant: 'combobox' with
    allowCustomValue: true and options built from customSubjectIds.

pnpm-workspace.yaml — catalog bumps that this feature requires:

Package From To
@douglasneuroinformatics/libui ^6.11.2 ^6.14.0
@douglasneuroinformatics/libui-form-types ^1.1.0 ^1.3.0

allowCustomValue does not exist before these versions. On the older ones the flag is silently
ignored, and Base UI's combobox reverts the input text to the selected item whenever the popup
closes — so a newly typed identifier was wiped the moment the clinician clicked away. 1.3.0 also
carries a TSDoc fix (@default@defaultValue) without which API Extractor fails
@opendatacapture/runtime-core's build, since that package inlines libui-form-types via
bundledPackages.

Storybook — the Default story now passes sample identifiers so the dropdown is exercised.

Tests

Unitapps/web/src/__tests__/start-session-form.test.tsx (new, 5 tests): submits an
identifier matching no existing subject; leaves that text visible in the input; offers in-use
identifiers as options; submits an identifier picked from the options; still rejects a custom
identifier containing the $ scope separator.

E2Etesting/src/specs/start-session.spec.ts (2 new tests): keeps a custom identifier when
the options popup is dismissed by clicking away (the exact regression), and starts a session for a
subject chosen from the existing identifiers. start-session.page.ts gains typeSubjectId,
dismissSubjectIdOptions, subjectIdOption and endSession, and its two fill helpers now share a
common fillSessionDetails rather than duplicating it.

Both tiers were confirmed collected, then watched to fail on purpose with allowCustomValue set to
false: 3 of 5 unit tests and 5 e2e tests go red — notably including three e2e tests that predate
this branch, since the combobox change makes them depend on the flag.

Verification

Gate Result
pnpm lint 33/33
pnpm test 83 files, 731 passed, 1 skipped
pnpm test:e2e 147/147

Known limitation

libui@6.14.0 declares libui-form-types@^1.1.0 and resolves its own copy, so the Form content
type in apps/web does not include the new combobox member. allowCustomValue is therefore
accepted as an unchecked excess property at the call site — a typo in the flag name compiles clean
and would silently disable the feature. The unit and e2e tests above are currently the only guard.
Deduping libui-form-types to a single version would close this; left out of scope here.

Closes issue #1216

code helped with claude Opus 5

@david-roper
david-roper requested a review from joshunrau as a code owner August 12, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant