Skip to content

Commit

Permalink
Merge pull request #22615 from gitstart/fix/color-input-buggy
Browse files Browse the repository at this point in the history
Controls: Throttling makes Color control lagging
  • Loading branch information
JReinhold authored May 15, 2024
2 parents 3e5fb46 + 2d39ba4 commit 879f979
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions code/ui/blocks/src/controls/Color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FC, ChangeEvent, FocusEvent } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { HexColorPicker, HslaStringColorPicker, RgbaStringColorPicker } from 'react-colorful';
import convert from 'color-convert';
import throttle from 'lodash/throttle.js';
import debounce from 'lodash/debounce.js';
import { styled } from '@storybook/theming';
import { TooltipNote, WithTooltip, Form } from '@storybook/components';

Expand Down Expand Up @@ -317,10 +317,10 @@ export const ColorControl: FC<ColorControlProps> = ({
startOpen = false,
argType,
}) => {
const throttledOnChange = useCallback(throttle(onChange, 200), [onChange]);
const debouncedOnChange = useCallback(debounce(onChange, 200), [onChange]);
const { value, realValue, updateValue, color, colorSpace, cycleColorSpace } = useColorInput(
initialValue,
throttledOnChange
debouncedOnChange
);
const { presets, addPreset } = usePresets(presetColors, color, colorSpace);
const Picker = ColorPicker[colorSpace];
Expand Down

0 comments on commit 879f979

Please sign in to comment.