headscale: key the server form to the server it edits
editing one server then another without closing in between reused the same mounted form, which seeds its fields at mount — so the second server showed the first one's name, url and ssh host. submit diffs that stale state against the new server prop, so saving would have written them to it.
This commit is contained in:
@@ -221,7 +221,16 @@ export const ServersView = () => {
|
||||
}
|
||||
/>
|
||||
|
||||
{formFor && <ServerForm server={formFor === 'new' ? null : formFor} onClose={() => setFormFor(null)} />}
|
||||
{/* Keyed by which server it edits: the form seeds its fields from the prop once, at mount, so
|
||||
switching straight from one server's Edit to another's would otherwise keep the first one's
|
||||
values — and submit diffs those stale values against the NEW server, writing them to it. */}
|
||||
{formFor && (
|
||||
<ServerForm
|
||||
key={formFor === 'new' ? 'new' : formFor.id}
|
||||
server={formFor === 'new' ? null : formFor}
|
||||
onClose={() => setFormFor(null)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{actionError && <ErrorNote>{actionError}</ErrorNote>}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user