Skip to content

feat: add exclusive options to set fields - #132

Merged
joshunrau merged 1 commit into
mainfrom
feat/set-field-exclusive-options
Nov 10, 2026
Merged

joshunrau merged 1 commit into
mainfrom
feat/set-field-exclusive-options

Conversation

@gdevenyi

Copy link
Copy Markdown
Contributor

Summary

Closes #127. Uses exclusiveOptions from DouglasNeuroInformatics/libui-form-types#23 (^1.6.0).

 isOptionDisabled(option)
+  if option is selected and exclusive
+    return false            # the user can always deselect it
+  return a different selected option is exclusive

 on(click option)
   if option is selected
     remove option
+  else if isOptionDisabled(option)
+    do nothing
+  else if option is exclusive
+    value = { option }      # deselects all other options
   else
     add option
 <SetField>
+  isOptionDisabled()
   <SetFieldListbox>
-    <Checkbox disabled={disabled || readOnly} />
+    <Checkbox disabled={disabled || readOnly || isOptionDisabled(option)} />
   <SetFieldSelect>
-    <DropdownMenu.CheckboxItem />
+    <DropdownMenu.CheckboxItem disabled={isOptionDisabled(option)} />
  • Open question in the issue: Option 1. A click on an exclusive option deselects the other options.
  • Values set from outside (for example initialValues) are not changed. The validation schema must enforce the rule if it is necessary.
  • Deviation from the literal rule in the issue: a selected exclusive option stays enabled. If two exclusive options are set from outside, the user can still deselect them.
  • New stories: WithExclusiveOption and SelectWithExclusiveOption.

Evidence

  • Before: with exclusiveOptions ignored in SetField.tsx, 9 of the 84 tests in src/components/Form fail (the new SetField.spec.tsx cases and the new Form.test.tsx case).
    After: pnpm lint passes. pnpm test: 42 files, 246 tests pass.
SetField.spec.tsx (listbox and select)
  select C (exclusive)        -> A, B, D disabled; click on A does nothing
  deselect C                  -> A, B, D enabled
  A, B selected, click C      -> value = { C }
  C, D exclusive              -> each one disables the other
  initial value { A, C }      -> not changed; deselect C gives { A }
  disabled / readOnly         -> all options disabled
Form.test.tsx
  exclusiveOptions in content -> reaches the field; submit gives Set { 'none' }

The checks ran on Node 26; engines asks for Node 24.x.

Merge Danger

Door: two-way

exclusiveOptions is optional. Fields without it behave as before. A revert removes the feature and has no effect on stored data.

Blast Radius: small

Only set fields that set exclusiveOptions change. The rule is enforced in the UI only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01W53iUSBaRj1XfMJBUUzmod

Add support for `exclusiveOptions` on set fields (listbox and select
variants). When an exclusive option is selected, all other options are
disabled until it is deselected. Selecting an exclusive option deselects
all other options.

Upgrade @douglasneuroinformatics/libui-form-types to ^1.6.0.

Closes #127

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W53iUSBaRj1XfMJBUUzmod
@gdevenyi
gdevenyi requested a review from joshunrau as a code owner November 10, 2026 03:30
Copilot AI balanced review requested due to automatic review settings November 10, 2026 03:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@joshunrau
joshunrau merged commit 98aa649 into main Nov 10, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 6.20.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: exclusive options for set fields (listbox / select)

3 participants