mirror of
https://github.com/wanderer-industries/wanderer
synced 2026-08-25 15:26:33 +00:00
Fix the bookmark custom mapping save behavior by moving the updateSetting side effect outside of the state setter function. This ensures the remote setting updates correctly when the input loses focus.
- fix(settings): Move `updateSetting` call outside of the `setLocalMapping` callback in `BookmarkNameFormatSetting`
This commit is contained in:
+12
-12
@@ -70,21 +70,21 @@ const CustomMappingInput = ({
|
||||
|
||||
const handleBlur = useCallback((e: React.FocusEvent<HTMLInputElement>) => {
|
||||
const val = e.target.value;
|
||||
setLocalMapping(prev => {
|
||||
const newMapping = { ...prev };
|
||||
if (val === defaultVal) {
|
||||
delete newMapping[mappingKey];
|
||||
} else {
|
||||
newMapping[mappingKey] = val;
|
||||
}
|
||||
|
||||
const newMapping = { ...localMapping };
|
||||
if (val === defaultVal) {
|
||||
delete newMapping[mappingKey];
|
||||
} else {
|
||||
newMapping[mappingKey] = val;
|
||||
}
|
||||
|
||||
const savedVal = savedMapping[mappingKey] !== undefined ? savedMapping[mappingKey] : defaultVal;
|
||||
if (val === savedVal) return newMapping;
|
||||
setLocalMapping(newMapping);
|
||||
|
||||
const savedVal = savedMapping[mappingKey] !== undefined ? savedMapping[mappingKey] : defaultVal;
|
||||
if (val !== savedVal) {
|
||||
updateSetting(UserSettingsRemoteProps.bookmark_custom_mapping, newMapping);
|
||||
return newMapping;
|
||||
});
|
||||
}, [mappingKey, defaultVal, savedMapping, setLocalMapping, updateSetting]);
|
||||
}
|
||||
}, [mappingKey, defaultVal, savedMapping, localMapping, setLocalMapping, updateSetting]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1 w-[120px]">
|
||||
|
||||
Reference in New Issue
Block a user