Skip to content

Commit

Permalink
fix: [color-picker] 修复颜色类型下拉框首次切换HSL,内部输入框值还是 RGB 格式的问题 fix #999
Browse files Browse the repository at this point in the history
  • Loading branch information
邵祺 authored and albyben committed Dec 13, 2024
1 parent 64413e2 commit 6ae8c6a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions components/color-picker/color-picker-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ const ColorPickerPanel: FC<IColorPickerPanelProps> = (props) => {

const handleClearClick = () => {
const formatArr = colorFormat(defaultSystemColor, 0) as IColorTypesObj[]
setPanelState(formatArr, defaultSystemColor, '', 0, '0%')
const defaultColor = colorFormat(
defaultSystemColor,
1,
currentColorType as Exclude<typeof ColorTypes[number], 'themeColor'>,
true,
) as string
setPanelState(formatArr, defaultColor, '', 0, '0%')
setClickColorIndex(-1)
onChange?.('', formatArr)
}
Expand Down Expand Up @@ -169,11 +175,11 @@ const ColorPickerPanel: FC<IColorPickerPanelProps> = (props) => {

const handleTypeChange = (selectValue: IColorTypesObj['type']) => {
setCurrentColorType(selectValue)
const colorStr = colTypeArr.find((item) => item.type === selectValue)?.value!
setCorrectColorValue(
colorFormat(colorStr, 1, selectValue as Exclude<typeof ColorTypes[number], 'themeColor'>, true) as string,
)
if (inputCorrectColorValue) {
const colorStr = colTypeArr.find((item) => item.type === selectValue)?.value!
setCorrectColorValue(
colorFormat(colorStr, 1, selectValue as Exclude<typeof ColorTypes[number], 'themeColor'>, true) as string,
)
setInputColorValue(colTypeArr.find((item) => item.type === format)?.value!)
onChange?.(colTypeArr.find((item) => item.type === format)?.value!, colTypeArr)
}
Expand Down

0 comments on commit 6ae8c6a

Please sign in to comment.