diff --git a/src/components/Calendar/CalendarColorPicker.tsx b/src/components/Calendar/CalendarColorPicker.tsx index df9521f..2337b22 100644 --- a/src/components/Calendar/CalendarColorPicker.tsx +++ b/src/components/Calendar/CalendarColorPicker.tsx @@ -8,7 +8,7 @@ import { Typography, useTheme, } from "@linagora/twake-mui"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import { HexColorPicker } from "react-colorful"; import { useI18n } from "twake-i18n"; import { defaultColors, getAccessiblePair } from "./utils/calendarColorsUtils"; @@ -27,6 +27,15 @@ export function ColorPicker({ ? selectedColor : undefined ); + + useEffect(() => { + if (!colors.find((c) => c.light === selectedColor?.light)) { + setCustomColor(selectedColor); + } else { + setCustomColor(undefined); + } + }, [selectedColor, colors]); + return ( {colors.map((c) => (