fix(settings): decode JSON-encoded values in settings UI#156
Draft
antosubash wants to merge 1 commit intomainfrom
Draft
fix(settings): decode JSON-encoded values in settings UI#156antosubash wants to merge 1 commit intomainfrom
antosubash wants to merge 1 commit intomainfrom
Conversation
…ettings Stored setting values are JSON-encoded (e.g. '"SimpleModule"', 'true', '42'), but SettingField rendered them raw — text inputs showed literal quotes around the value. Decode based on SettingType for display and re-encode on save so the round-trip stays consistent with SettingsService<T> deserialization.
Deploying simplemodule-website with
|
| Latest commit: |
4ac1f08
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5db43ce6.simplemodule-website.pages.dev |
| Branch Preview URL: | https://claude-fix-settings-display.simplemodule-website.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Setting values are stored JSON-encoded (e.g.
"\"SimpleModule\"","true","42") soSettingsService.GetSettingAsync<T>()canJsonSerializer.Deserialize<T>them. The ReactSettingFieldrendered the raw stored string, so:"SimpleModule"instead ofSimpleModule).Changes
modules/Settings/src/SimpleModule.Settings/components/SettingField.tsx:decodeForDisplay(stored, type)— parses the stored JSON and returns the human-readable form perSettingType(Text → string, Number → numeric string, Bool →true/false, JSON → pretty-printed).encodeForStorage(input, type)— re-encodes the user input as JSON before sending to the API so the round-trip survives.JSON.parsebefore save and surfaces the parser error inline instead of silently posting invalid JSON.id={definition.key}so the existing<label htmlFor>inSettingGroup/UserSettingsactually associates with the control.Falls back to the raw stored string if
JSON.parsefails (handles legacy unencoded data already in the DB).Test plan
npm run checkpasses (biome + typecheck + page validation).dotnet test modules/Settings/...— 27 existing settings tests pass./settings(admin) and/settings/me(user); verify text fields render unquoted, toggles reflect the boolean state, JSON area shows pretty-printed JSON.Generated by Claude Code