Custom identifier combobox with allowCustomValue flag - #1508
Open
david-roper wants to merge 6 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suggest existing custom identifiers on the Start Session form
The identifier field for the
CUSTOM_IDidentification method was a free-text input, so aclinician 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.tsxloaderthat prefetchessubjectsQueryOptions({ params: { groupId } })into React Query,and a matching
useSubjectsQueryin the component, per the repo's data-hook convention (loaderand component share one key).
customSubjectIdsfrom that data: subjects with no personal info, with the group scopeprefix stripped via
removeSubjectIdScope.apps/web/src/components/StartSessionForm/StartSessionForm.tsxcustomSubjectIds: string[]prop.subjectIdfield goes fromvariant: 'input'tovariant: 'combobox'withallowCustomValue: trueandoptionsbuilt fromcustomSubjectIds.pnpm-workspace.yaml— catalog bumps that this feature requires:@douglasneuroinformatics/libui^6.11.2^6.14.0@douglasneuroinformatics/libui-form-types^1.1.0^1.3.0allowCustomValuedoes not exist before these versions. On the older ones the flag is silentlyignored, 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.0alsocarries a TSDoc fix (
@default→@defaultValue) without which API Extractor fails@opendatacapture/runtime-core's build, since that package inlineslibui-form-typesviabundledPackages.Storybook — the
Defaultstory now passes sample identifiers so the dropdown is exercised.Tests
Unit —
apps/web/src/__tests__/start-session-form.test.tsx(new, 5 tests): submits anidentifier 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.E2E —
testing/src/specs/start-session.spec.ts(2 new tests): keeps a custom identifier whenthe 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.tsgainstypeSubjectId,dismissSubjectIdOptions,subjectIdOptionandendSession, and its two fill helpers now share acommon
fillSessionDetailsrather than duplicating it.Both tiers were confirmed collected, then watched to fail on purpose with
allowCustomValueset tofalse: 3 of 5 unit tests and 5 e2e tests go red — notably including three e2e tests that predatethis branch, since the combobox change makes them depend on the flag.
Verification
pnpm lintpnpm testpnpm test:e2eKnown limitation
libui@6.14.0declareslibui-form-types@^1.1.0and resolves its own copy, so theFormcontenttype in
apps/webdoes not include the new combobox member.allowCustomValueis thereforeaccepted 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-typesto a single version would close this; left out of scope here.Closes issue #1216
code helped with claude Opus 5