~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

A group's join setting and country keep a choice made before the page hydrates

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:console/select-defaults

On a slow load, a group's profile form put a join setting or a country picked before the page hydrated back to the saved one, and saving then said "Saved" while keeping the old value. Both selects now keep what was picked, and the saved town is drawn by the server rather than appearing once the page hydrates.

Claude Opus 5.5

What changes

ProfileForm.svelte, the profile form in a group's settings:

  • The join setting and country are <select defaultValue={...}> rather than value={...}. Svelte sets a value again as the page hydrates, selecting the saved option over the one picked; defaultValue marks the saved option (the selected attributes the server drew), keeps the selection a person made, and is what a form reset goes back to.
  • The town is a writable $derived of the saved one, rather than $state set by an $effect.pre. Effects do not run on the server, so the field was drawn empty and filled in only once the page hydrated; now the server draws it. Typing over it before or after hydration keeps what was typed, and a save that changes it brings the saved one back.

Why

The e2e flow "joining a group anyone can join" failed so on slow runs (fixed for the flows by at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.pull/3n2mw3rmp6fub, which waits for hydration); a person on a slow connection loses their pick the same way. defaultValue is Svelte's way of setting a select's starting value without taking the selection from the person.

How it was checked

A throwaway Playwright script against a just look world, signed in as alice on Riders' settings, with the page's scripts held back:

join settingcountrytown
picked before hydrating (open, NZ, Wellington), old formapproval(none)Wellington
the same, this formopenNZWellington

Saving Oakland, United States and invite-only as a person would, the form shows them after saving; loaded again with scripts held, the server draws all three (before, the town was empty until hydrated), and hydrating keeps them. npm run check (svelte-check and the shell's types) passes; the form drawn with just look is as it was.

Shortcomings

  • Only the profile form had selects set from saved state; other forms' fields are inputs, which Svelte already keeps when typed into before hydrating.

profile-form-alice-desktop-light.png

Approved

This pull changes the join-setting and country selects in ProfileForm.svelte from value to defaultValue. A choice made before hydration is no longer reset to the saved value. It also makes the town a writable $derived of the saved town, so the server draws it instead of it appearing after hydration.

I read the diff and did not run it. It matches the pull's description, and I found nothing wrong.

One thing to watch: with defaultValue, a saved value that changes without the user picking it may not move the selection. An example is a value changed from another tab and then loaded into the same form instance. Your Playwright check covers the normal save, where the user's pick matches the saved value. That is acceptable here.

Merged as 8df9527