From aeb479b67ada241b236b9e131da4f0f901e738cc Mon Sep 17 00:00:00 2001 From: Drew Bonasera Date: Fri, 29 May 2026 03:56:20 -0400 Subject: [PATCH] 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` --- .../components/BookmarkNameFormatSetting.tsx | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/BookmarkNameFormatSetting.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/BookmarkNameFormatSetting.tsx index de3ca4ce..2defe092 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/BookmarkNameFormatSetting.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/BookmarkNameFormatSetting.tsx @@ -70,21 +70,21 @@ const CustomMappingInput = ({ const handleBlur = useCallback((e: React.FocusEvent) => { 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 (