Skip to content

Add enforceValueInOptions prop to Select - #4485

Draft
lbwexler wants to merge 1 commit into
developfrom
select-enforce-value-in-options
Draft

Add enforceValueInOptions prop to Select#4485
lbwexler wants to merge 1 commit into
developfrom
select-enforce-value-in-options

Conversation

@lbwexler

Copy link
Copy Markdown
Member

Adds an opt-in enforceValueInOptions prop to the desktop and mobile Select components, addressing #4111.

When enabled, the control keeps its value constrained to the current options: whenever either the value or the options list changes, any selected value not found in options is automatically removed — cleared to emptyValue for single selects, or filtered out of the array for multi (desktop). This replaces the app-level reactions teams write today to reconcile a selection against reloaded options.

Notes

  • Enforces on both triggers (options reload and a value set/bind) via a reaction tracking both, so the invariant holds regardless of which side changed. Idempotent, so no reaction loop.
  • Throws if combined with enableCreate or queryFn, where values may legitimately fall outside options.
  • Because it fires immediately, a value set before options load will be removed — documented on the prop; not for use alongside late-loading options / generateOptionFn.

Closes #4111

Opt-in prop that keeps a Select's value constrained to its current options: when either the value or the options list changes, any selected value not found in options is automatically removed - cleared to emptyValue (single) or filtered out of the array (multi, desktop). Replaces app-level reactions that manually reconcile selection against options.

- Enforces on both triggers (options reload and value set/bind) via a reaction tracking both, so the invariant holds regardless of which side changed.
- Throws if combined with enableCreate or queryFn, where values may legitimately fall outside options.

Closes #4111
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.

Add toggle for automatically removing select() values on options change

1 participant