ant-design / ant-design/pro-components

🐛[BUG] ProFormColorPicker未按照预期赋值及禁用透明色无效

Open
#8,151 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.8k
Forks
1.4k
Avg merge
10h 44m
Merged PRs (30d)
3

Description

### 🐛 bug 描述

1. 在ModalForm中使用 formRef.current?.setFieldsValue({ }) 为ProFormColorPicker设置颜色 仅点开组件后输入框内有值;
2. ProFormColorPicker设置 fieldProps={{ disableAlpha: true }} 禁用透明色无效

### 📷 复现步骤

见下方复现代码

### 🏞 期望结果
图中红色框位置颜色同步及禁用透明效果

image

### 💻 复现代码

`tsx
import { useState, useRef } from "react";
import { ModalForm, ProFormColorPicker } from "@ant-design/pro-components";

export default function App() {
const [open, setOpen] = useState(false);

const formRef = useRef(null);

return (


{
setOpen(true);
formRef.current?.setFieldsValue({ color: "#f00" });
}}
/>




);
}
`

### © 版本信息

- "@ant-design/pro-components": "^2.6.48"
- node v21.4.0
- npm 10.2.4
- Chrom 版本 121.0.6167.85(正式版本) (arm64)
- 开发环境 [mac OS 14.3 (23D56)]

Contributor guide

Open the contributing guide

Research direction

Start with the ProFormColorPicker and ModalForm integration shown in the reproduction code, then run that example to observe both reported behaviors. Trace how the form value reaches the color picker and how fieldProps is passed through. Done means #f00 appears before opening the picker and disableAlpha prevents transparent colors.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.