Repository navigation
Description
Summary
Split off #5182, which fixed this for the embedding model section only.
useFormEditor takes Save's validity from react-hook-form's stored formState.isValid (packages/ui/src/components/editor/use-form-editor.ts:237). That stored value goes stale in two cases:
- A handler changes a value with
setValuewithoutshouldValidate, after RHF has already judged the form, for example after a field's ownonChange. RHF does not run the schema again. - A save fails its schema. A failed
handleSubmitwrites the errors but leavesisValidas it was.
An audit of the eight other editors that call setValue this way found two that show a wrong Save state today.
Everything below was read from the code at main 11aac22 with react-hook-form 7.72.1. None of it was reproduced in a browser or a test.
Object storage: Save is on while required fields are blank
File: services/platform/app/features/settings/data-residency/components/org-storage-section.tsx
- Cause:
- The Force path style toggle is written with
setValue('forcePathStyle', checked, { shouldDirty: true })(:604-607). It is not a registered input, so nothing runs the schema again. - The schema treats the untouched empty form as valid while no storage is configured (
:259). Any other values make Region and Bucket required.
- The Force path style toggle is written with
- Steps:
- Use an organization with no storage connection.
- Turn the section on.
- Make Force path style the first edit.
- Result:
- The header's Save is on while Region and Bucket are blank.
- A click refuses with "Fix the highlighted fields and try again" and marks Region and Bucket. Save stays on.
- In a grouped save, the sections saved before this one are already saved when it fails.
Enterprise SSO: Save is off over valid values
File: services/platform/app/features/settings/enterprise-sso/components/enterprise-sso-form.tsx
- Cause:
- The protocol select calls
field.onChange(next)first (:904), which judges the form as it stands. - Only then does
setValue('displayName', …, { shouldDirty: true })(:921-923) fill an empty or default name, and nothing judges the form again.
- The protocol select calls
- Steps:
- Start from an OIDC connection that is otherwise valid.
- Clear Display name. Save turns off, which is correct.
- Leave the field, so its "required" error shows.
- Switch between Generic OIDC and Entra ID, or from OAuth2 to either one.
- Result:
- The name is filled, but the stale "required" error stays under it.
- Save stays off with no reason until the next edit or blur.
- Switches that mount new inputs (to OAuth2 or SAML, or away from SAML) validate again and are not affected.
- A timing case with the same cause:
- The revealed client id is written with
setValue('clientId', value, { shouldDirty: false })(:659). - An edit made before the reveal returns judges the form with an empty client id.
- Save then stays off, with no error anywhere, until the next edit.
- Bug: delayed SSO client-ID loading overwrites a newer edit #3925 fixed the same reveal overwriting a newer edit; this is the validity side of that reveal.
- The revealed client id is written with
Not affected
These use the same pattern, but the value they set cannot change validity:
settings/sandboxes/workspace-cleanup-editor.tsxsettings/governance/components/chat-tools-policy-editor.tsxsettings/governance/components/vision-model-editor.tsxsettings/governance/components/skill-sharing-policy-editor.tsxprojects/components/project-task-reviewer-section.tsxprojects/components/project-overview.tsx: only a stored icon or colour outside the allowed list could be affected, and no current write path stores one.
Constraints a change must respect
- No early errors. No error appears on a field the admin has not reached yet.
- Existing rules keep their meaning. Refusals keep Save off, and the empty-section rules stay valid.
- A fix per site needs care.
shouldValidate, ortrigger(<the set field>), recomputesisValidbut writes only that field's error. Save would then turn off with no visible reason, which is what bug(platform): Embedding model Save is on with empty fields after a provider change, and off without a reason once a model is picked #5182's model pick did. - A shared fix would cover every editor at once.
useFormEditorcould recompute validity whenever the values change.trigger([])recomputesisValidwithout writing any error.- Validity after a failed save belongs to the same fix.
- Tests stay green. The data-residency tests of bug(platform): Embedding model Save is on with empty fields after a provider change, and off without a reason once a model is picked #5182 pin the embedding section's states.
Related
- bug(platform): Embedding model Save is on with empty fields after a provider change, and off without a reason once a model is picked #5182: the parent issue, and the embedding section's fix.
- feat(ui): say why a form editor's Save is off #5261: a reason on a disabled Save.
Activity
fix(ui): keep a form editor's Save current when code sets a field
docs: write the v0.5.96 release notes
docs: write the v0.5.96 release notes