Skip to content

fix(forms): Reserve space for auto-save indicator to prevent layout shift#114292

Merged
TkDodo merged 1 commit intomasterfrom
tkdodo/fix/indicator-fallback
Apr 30, 2026
Merged

fix(forms): Reserve space for auto-save indicator to prevent layout shift#114292
TkDodo merged 1 commit intomasterfrom
tkdodo/fix/indicator-fallback

Conversation

@TkDodo
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo commented Apr 29, 2026

When AutoSaveForm fields show the save indicator (spinner/checkmark), the indicator appearing and disappearing causes adjacent content to shift. This is especially noticeable for standalone switches (e.g. the spike protection toggle on the settings page) where the indicator pushes neighboring elements sideways.

The fix reserves a 14px placeholder Flex when the indicator is not visible, matching the indicator's width. The placeholder is only rendered inside an AutoSaveForm context (autoSaveContext is non-null), so fields used outside of auto-save forms are unaffected.

Applied consistently to SwitchField, RadioField, and RangeField. SwitchField previously had no placeholder at all; RadioField and RangeField unconditionally rendered the placeholder even outside auto-save forms.

…hift

When AutoSaveForm fields show the save indicator (spinner/checkmark),
the indicator appearing and disappearing causes adjacent content to
shift. Reserve a 14px placeholder when the indicator is not visible,
but only inside an AutoSaveForm context so non-auto-save usage is
unaffected.

Apply to SwitchField, RadioField, and RangeField consistently.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 29, 2026
@TkDodo TkDodo marked this pull request as ready for review April 29, 2026 11:18
@TkDodo TkDodo requested a review from a team as a code owner April 29, 2026 11:18
@TkDodo TkDodo merged commit 0ea0ae9 into master Apr 30, 2026
68 checks passed
@TkDodo TkDodo deleted the tkdodo/fix/indicator-fallback branch April 30, 2026 06:45
TkDodo added a commit that referenced this pull request May 3, 2026
…14293)

Migrates the spike protection toggle from the legacy `BooleanField` /
`FormField` system to `AutoSaveForm` with `field.Switch` from the new
TanStack-based form system.

**What changed:**

- `spikeProtectionProjectToggle.tsx` — replaced `BooleanField` + manual
`useState`/`useApi` with `AutoSaveForm`. The POST/DELETE API pattern
(POST to enable, DELETE to disable) is handled in `mutationFn`. After a
successful toggle, `ProjectsStore` is updated so that the project
settings page (which reads from `ProjectContext` → `ProjectsStore`)
reflects the new state without a full page reload.
- `spikeProtectionProjectSettings.tsx` — replaced
`Panel`/`PanelBody`/`PanelHeader` with `FieldGroup` for consistency with
other migrated settings forms.
- `spikeProtectionProjects.tsx` — removed `StyledPanelToggle` (which
targeted legacy `FormField` CSS internals), replaced
`AccordionRowContainer` with `Flex`, and cleaned up the `any` type cast
on the `onChange` callback.
- Added a test verifying `ProjectsStore.onUpdateSuccess` is called after
a successful toggle.

The toggle is used in two places: the spike protection settings list
page (`settings/spike-protection/`) and the general project settings
page (embedded via `<Hook>`). Both continue to work — the `<Hook>`
component fix in #114289 ensures the toggle's mutation state survives
parent re-renders on the project settings page.

Refs DE-1191

depends on:

- #114289
- #114292
cleptric pushed a commit that referenced this pull request May 5, 2026
…hift (#114292)

When AutoSaveForm fields show the save indicator (spinner/checkmark),
the indicator appearing and disappearing causes adjacent content to
shift. This is especially noticeable for standalone switches (e.g. the
spike protection toggle on the settings page) where the indicator pushes
neighboring elements sideways.

The fix reserves a 14px placeholder `Flex` when the indicator is not
visible, matching the indicator's width. The placeholder is only
rendered inside an `AutoSaveForm` context (`autoSaveContext` is
non-null), so fields used outside of auto-save forms are unaffected.

Applied consistently to `SwitchField`, `RadioField`, and `RangeField`.
`SwitchField` previously had no placeholder at all; `RadioField` and
`RangeField` unconditionally rendered the placeholder even outside
auto-save forms.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
cleptric pushed a commit that referenced this pull request May 5, 2026
…14293)

Migrates the spike protection toggle from the legacy `BooleanField` /
`FormField` system to `AutoSaveForm` with `field.Switch` from the new
TanStack-based form system.

**What changed:**

- `spikeProtectionProjectToggle.tsx` — replaced `BooleanField` + manual
`useState`/`useApi` with `AutoSaveForm`. The POST/DELETE API pattern
(POST to enable, DELETE to disable) is handled in `mutationFn`. After a
successful toggle, `ProjectsStore` is updated so that the project
settings page (which reads from `ProjectContext` → `ProjectsStore`)
reflects the new state without a full page reload.
- `spikeProtectionProjectSettings.tsx` — replaced
`Panel`/`PanelBody`/`PanelHeader` with `FieldGroup` for consistency with
other migrated settings forms.
- `spikeProtectionProjects.tsx` — removed `StyledPanelToggle` (which
targeted legacy `FormField` CSS internals), replaced
`AccordionRowContainer` with `Flex`, and cleaned up the `any` type cast
on the `onChange` callback.
- Added a test verifying `ProjectsStore.onUpdateSuccess` is called after
a successful toggle.

The toggle is used in two places: the spike protection settings list
page (`settings/spike-protection/`) and the general project settings
page (embedded via `<Hook>`). Both continue to work — the `<Hook>`
component fix in #114289 ensures the toggle's mutation state survives
parent re-renders on the project settings page.

Refs DE-1191

depends on:

- #114289
- #114292
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.

3 participants