Skip to content

feat(form): SwitchField#108212

Merged
TkDodo merged 3 commits intomasterfrom
tkdodo/feat/de-913-switchfield
Feb 13, 2026
Merged

feat(form): SwitchField#108212
TkDodo merged 3 commits intomasterfrom
tkdodo/feat/de-913-switchfield

Conversation

@TkDodo
Copy link
Collaborator

@TkDodo TkDodo commented Feb 13, 2026

A new <field.Switch>, which renders the core switch component as a form field

@linear
Copy link

linear bot commented Feb 13, 2026

DE-913 switchField

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 13, 2026
Comment on lines +136 to +138
// Boolean fields (like switches) save on change, others save on blur
const fieldSchema = schema.shape[name];
const saveOnChange = fieldSchema ? isBooleanField(fieldSchema) : false;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the problem is that some fields should auto-save immediately, onChange, not onBlur. Since we have a schema, we can auto detect this for boolean fields

@TkDodo TkDodo marked this pull request as ready for review February 13, 2026 12:58
@TkDodo TkDodo requested a review from a team as a code owner February 13, 2026 12:58
checkbox.focus();
expect(checkbox).not.toBeChecked();

await userEvent.keyboard(' ');
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for adding tests for this 🙏🏼

Copy link
Member

@JonasBa JonasBa left a comment

Choose a reason for hiding this comment

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

The tests, JSX and the logic behind the form system is just so enjoyable to read, nice work!

@TkDodo TkDodo merged commit 00b84d0 into master Feb 13, 2026
62 checks passed
@TkDodo TkDodo deleted the tkdodo/feat/de-913-switchfield branch February 13, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants