From 894273f73b81c4f76273c787aa1b570581ac0fba Mon Sep 17 00:00:00 2001 From: wuxx <1239378684@qq.com> Date: Tue, 5 Nov 2024 14:44:37 +0800 Subject: [PATCH 1/2] fix(color-picker): recentColors delete --- src/color-picker/panel/swatches.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/color-picker/panel/swatches.tsx b/src/color-picker/panel/swatches.tsx index a5467d697..9e8f4aed5 100644 --- a/src/color-picker/panel/swatches.tsx +++ b/src/color-picker/panel/swatches.tsx @@ -69,13 +69,10 @@ export default defineComponent({ * 移除颜色 */ const handleRemoveColor = () => { - const colors = [...props.colors]; + const colors = props.colors; const selectedIndex = selectedColorIndex.value; - if (selectedIndex > -1) { - colors.splice(selectedIndex, 1); - } else { - colors.length = 0; - } + if (selectedIndex === -1) return + colors.splice(selectedIndex, 1); props.handleChange?.(colors); setVisiblePopConfirm(false); }; From e8ada59510fa46e02b9b68e75e92ae4862998913 Mon Sep 17 00:00:00 2001 From: wuxx <1239378684@qq.com> Date: Tue, 5 Nov 2024 16:02:04 +0800 Subject: [PATCH 2/2] fix(color-picker): format --- src/color-picker/panel/index.tsx | 4 ++-- src/color-picker/panel/swatches.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/color-picker/panel/index.tsx b/src/color-picker/panel/index.tsx index d637a6a01..cb4032613 100644 --- a/src/color-picker/panel/index.tsx +++ b/src/color-picker/panel/index.tsx @@ -283,10 +283,10 @@ export default defineComponent({ }, render() { const { - baseClassName, statusClassNames, t, global, recentColors, swatchColors, previewColorStyle, isGradient, + baseClassName, statusClassNames, t, global, swatchColors, previewColorStyle, isGradient, } = this; - const showUsedColors = recentColors !== null && recentColors !== false; + const showUsedColors = this.recentlyUsedColors !== null && this.recentlyUsedColors !== false; let systemColors = swatchColors; if (systemColors === undefined) { diff --git a/src/color-picker/panel/swatches.tsx b/src/color-picker/panel/swatches.tsx index 9e8f4aed5..adfdc7cff 100644 --- a/src/color-picker/panel/swatches.tsx +++ b/src/color-picker/panel/swatches.tsx @@ -69,9 +69,9 @@ export default defineComponent({ * 移除颜色 */ const handleRemoveColor = () => { - const colors = props.colors; + const { colors } = props; const selectedIndex = selectedColorIndex.value; - if (selectedIndex === -1) return + if (selectedIndex === -1) return; colors.splice(selectedIndex, 1); props.handleChange?.(colors); setVisiblePopConfirm(false);