File tree Expand file tree Collapse file tree 1 file changed +21
-17
lines changed
x-pack/plugins/lens/public/xy_visualization Expand file tree Collapse file tree 1 file changed +21
-17
lines changed Original file line number Diff line number Diff line change @@ -188,23 +188,27 @@ const ColorPicker = ({
188188 }
189189 } ;
190190
191- const updateColorInState : EuiColorPickerProps [ 'onChange' ] = debounce ( ( text , output ) => {
192- const newYConfigs = [ ...( layer . yConfig || [ ] ) ] ;
193- const existingIndex = newYConfigs . findIndex ( ( yConfig ) => yConfig . forAccessor === accessor ) ;
194- if ( existingIndex !== - 1 ) {
195- if ( text === '' ) {
196- delete newYConfigs [ existingIndex ] . color ;
197- } else {
198- newYConfigs [ existingIndex ] . color = output . hex ;
199- }
200- } else {
201- newYConfigs . push ( {
202- forAccessor : accessor ,
203- color : output . hex ,
204- } ) ;
205- }
206- setState ( updateLayer ( state , { ...layer , yConfig : newYConfigs } , index ) ) ;
207- } , 256 ) ;
191+ const updateColorInState : EuiColorPickerProps [ 'onChange' ] = React . useMemo (
192+ ( ) =>
193+ debounce ( ( text , output ) => {
194+ const newYConfigs = [ ...( layer . yConfig || [ ] ) ] ;
195+ const existingIndex = newYConfigs . findIndex ( ( yConfig ) => yConfig . forAccessor === accessor ) ;
196+ if ( existingIndex !== - 1 ) {
197+ if ( text === '' ) {
198+ delete newYConfigs [ existingIndex ] . color ;
199+ } else {
200+ newYConfigs [ existingIndex ] . color = output . hex ;
201+ }
202+ } else {
203+ newYConfigs . push ( {
204+ forAccessor : accessor ,
205+ color : output . hex ,
206+ } ) ;
207+ }
208+ setState ( updateLayer ( state , { ...layer , yConfig : newYConfigs } , index ) ) ;
209+ } , 256 ) ,
210+ [ state , layer , accessor , index ]
211+ ) ;
208212
209213 return (
210214 < EuiToolTip
You can’t perform that action at this time.
0 commit comments