refactoring-backend #3
@@ -1,24 +1,3 @@
|
||||
### TASK-BUG-02 — `ConfigPage` Tab Switch Destroys All Form State
|
||||
|
||||
**Where found**
|
||||
`frontend/src/pages/ConfigPage.tsx`. The active tab content is wrapped in a `<div key={tab}>`. Changing `key` forces React to unmount the old subtree and mount a brand-new one. `JailConfigDetail` alone has 20+ `useState` fields (banTime, findTime, maxRetry, failRegex, ignoreRegex, logPaths, datePattern, dnsMode, backend, logEncoding, prefRegex, plus all ban-time escalation fields). All of these are reset when the user switches tabs and switches back.
|
||||
|
||||
**Goal**
|
||||
Remove the `key={tab}` from the wrapping `<div>` and instead conditionally render each tab panel using `display: none` / `display: block` (or Fluent UI `TabPanel` visibility) so components stay mounted throughout the page lifetime. Alternatively, lift the shared state up to `ConfigPage` or a context so it survives remounts. The simplest fix is removing the key and using CSS visibility.
|
||||
|
||||
**Possible traps and issues**
|
||||
- Hidden tabs still run their hooks (data fetches, effects). This is acceptable because the tabs are already mounted when the page loads; the behaviour becomes consistent rather than worse.
|
||||
- If tab-specific effects must fire on "tab activation" they need to be converted from key-based remount triggers to explicit activation flags.
|
||||
- Auto-save in `JailConfigDetail` uses `useAutoSave` which has its own pending-save debounce. Keeping the component mounted means a pending save from one session survives correctly across tab switches, which is the desired behaviour.
|
||||
|
||||
**Docs changes needed**
|
||||
Update `Docs/Web-Development.md` to note that tab panels must not use `key` for tab identity.
|
||||
|
||||
**Why this is needed**
|
||||
Users editing a jail config (filling in ban time, regex patterns, log paths) lose all unsaved changes if they accidentally click another tab and return. The auto-save timer is also cancelled, silently dropping work.
|
||||
|
||||
---
|
||||
|
||||
### TASK-BUG-03 — MapPage Pagination Resets on Every Data Refresh
|
||||
|
||||
**Where found**
|
||||
|
||||
Reference in New Issue
Block a user