File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
custom-component-library/components/ColorPicker Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,11 @@ export const ColorPickerComponent: React.FC<CustomNodeProps<ColorPickerProps>> =
6868 const [ hsvValue , setHsvValue ] = React . useState ( colord ( text ) . toHsv ( ) )
6969
7070 const lastValidColor = useRef ( text )
71+ const isUpdatingFromPicker = useRef ( false )
7172
7273 // Debounced setValue to avoid excessive updates while dragging the picker
7374 const debouncedSetValue = useDebouncedCallback ( ( value : string ) => {
75+ isUpdatingFromPicker . current = true
7476 setValue ( value )
7577 } , 150 )
7678
@@ -97,6 +99,12 @@ export const ColorPickerComponent: React.FC<CustomNodeProps<ColorPickerProps>> =
9799 value = { text }
98100 setValue = {
99101 ( ( value : string ) => {
102+ // Prevent infinite loop when update is coming from color picker
103+ if ( isUpdatingFromPicker . current ) {
104+ isUpdatingFromPicker . current = false // Reset immediately
105+ return
106+ }
107+
100108 // Only update the color picker display if the input text is a
101109 // valid color
102110 const parsed = colord ( value )
You can’t perform that action at this time.
0 commit comments