Skip to content

Commit

Permalink
fix(ColorPicker): fix recentColors delete bug (#4720)
Browse files Browse the repository at this point in the history
* fix(color-picker): recentColors delete

* fix(color-picker): recentColors delete

* fix(color-picker): lint format

* fix(color-picker): lint format
  • Loading branch information
superNos authored Nov 13, 2024
1 parent 15d8392 commit 2e3e2cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
14 changes: 3 additions & 11 deletions src/color-picker/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,21 +272,13 @@ export default defineComponent({
};
},
render() {
const {
t,
baseClassName,
statusClassNames,
globalConfig,
recentColors,
swatchColors,
showPrimaryColorPreview,
isGradient,
} = this;
const { t, baseClassName, statusClassNames, globalConfig, swatchColors, showPrimaryColorPreview, isGradient } =
this;
const baseProps = {
color: this.color,
disabled: this.disabled,
};
const showUsedColors = recentColors !== null && recentColors !== false;
const showUsedColors = this.recentlyUsedColors !== null && this.recentlyUsedColors !== false;

let systemColors = swatchColors;
if (systemColors === undefined) {
Expand Down
9 changes: 3 additions & 6 deletions src/color-picker/panel/swatches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,10 @@ export default defineComponent({
* 移除颜色
*/
const handleRemoveColor = () => {
const colors = [...props.colors];
const { colors } = props;
const selectedIndex = selectedColorIndex.value;
if (selectedIndex > -1) {
colors.splice(selectedIndex, 1);
} else {
colors.length = 0;
}
if (selectedIndex === -1) return;
colors.splice(selectedIndex, 1);
props.onChange(colors);
setVisiblePopConfirm(false);
};
Expand Down

0 comments on commit 2e3e2cd

Please sign in to comment.