You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: code config values and UI settings save both ignored defaults
Two bugs fixed:
1. Server (setup.ts): `plugins.ts` code config values were silently
ignored for any key that already had a hard-coded default. The
original code merged `configBase.default` into `configRaw` before
building the priority chain, so the hard-coded default always won.
Fixed by separating the raw DB read (`dbConfig`) from the Zod
validation object, then applying the correct priority order:
DB value → code config (plugins.ts) → hard-coded default.
2. UI (AdditionalSettingsPanel): `NumberInput` from @strapi/design-system
exposes the parsed number via `onValueChange`, not `onChange`. The
previous `onChange` handler received a raw value that was not a
string field name, so `isString(fieldName)` evaluated to false and
`setFormValueItem` was never called. `formValue.allowedLevels` stayed
at 2 while the input display (driven by the Form component's internal
`values`) correctly showed the user's input — causing the stale value
to be submitted on save. Fixed by switching to `onValueChange`.
Also included:
- useInitialConfig: guard with useRef so the form is only seeded from
the server once per mount, preventing background refetches from
overwriting user edits
- useSaveConfig: invalidate the config query after a successful save
- SettingsPage: move queryClient.invalidateQueries() into useEffect so
it runs once on mount instead of on every render
- Test infrastructure: add outDir to server/tsconfig.json and tsconfig
path to jest.config.ts so ts-jest resolves correctly
- Regression test: configSetup respects code config allowedLevels when
DB is empty
0 commit comments