Skip to content

Commit d2ef08e

Browse files
committed
actually fixed infinity theme saving
1 parent eec1129 commit d2ef08e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

frontend/src/components/buttons/themeSwitch/CustomColorPicker.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ function CustomColorPicker( {name, currentColor, onChange, lineColor, borderColo
77
const [isPickerOpened, setIsPickerOpened] = useState(false);
88
const pickerRef = useRef(null);
99

10+
const prevIsPickerOpened = useRef(isPickerOpened);
11+
1012
const { isMobile } = useDeviceContext();
1113

1214
function handleTileClick() {
@@ -18,9 +20,12 @@ function CustomColorPicker( {name, currentColor, onChange, lineColor, borderColo
1820
};
1921

2022
useEffect(() => {
21-
if (!isPickerOpened && onClose) {
22-
onClose();
23+
if (prevIsPickerOpened.current === true && isPickerOpened === false) {
24+
if (onClose) {
25+
onClose();
26+
}
2327
}
28+
prevIsPickerOpened.current = isPickerOpened;
2429
}, [isPickerOpened, onClose]);
2530

2631
useEffect(() => {

frontend/src/components/contexts/ThemeContext.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function ThemeProvider({ children }) {
5252
]);
5353

5454
function saveColorThemeFromContext() {
55-
//console.log("Saving theme...", colorTheme);
55+
console.log("Saving theme...", colorTheme);
5656
saveColorTheme(colorTheme);
5757
}
5858

0 commit comments

Comments
 (0)