diff --git a/components/color-picker/__tests__/index.test.tsx b/components/color-picker/__tests__/index.test.tsx index 913309a1a9..161b4b6926 100644 --- a/components/color-picker/__tests__/index.test.tsx +++ b/components/color-picker/__tests__/index.test.tsx @@ -248,7 +248,7 @@ describe('ColorPicker', () => { { label: 'Recent', colors: ['#f00d', '#0f0d', '#00fd'], - defaultCollapsed: true, + defaultOpen: false, }, ]} />, diff --git a/components/color-picker/components/ColorPresets.tsx b/components/color-picker/components/ColorPresets.tsx index 12fa5cd21f..adbc137f18 100644 --- a/components/color-picker/components/ColorPresets.tsx +++ b/components/color-picker/components/ColorPresets.tsx @@ -48,9 +48,8 @@ const ColorPresets: FC = ({ prefixCls, presets, value: color, const activeKeys = useMemo( () => presetsValue.reduce((acc, preset) => { - if (!preset.defaultCollapsed) { - acc.push(genCollapsePanelKey(preset)); - } + const { defaultOpen = true } = preset; + if (defaultOpen) acc.push(genCollapsePanelKey(preset)); return acc; }, []), [presetsValue], diff --git a/components/color-picker/index.en-US.md b/components/color-picker/index.en-US.md index f2a6f61037..a9ca6338a4 100644 --- a/components/color-picker/index.en-US.md +++ b/components/color-picker/index.en-US.md @@ -53,7 +53,7 @@ Common props ref:[Common props](/docs/react/common-props) | destroyTooltipOnHide | Whether destroy popover when hidden | `boolean` | false | 5.7.0 | | format | Format of color | `rgb` \| `hex` \| `hsb` | `hex` | | | open | Whether to show popup | boolean | - | | -| presets | Preset colors | `{ label: ReactNode, colors: Array, defaultCollapsed?: boolean }[]` | - | `defaultCollapsed: 5.11.0` | +| presets | Preset colors | `{ label: ReactNode, colors: Array, defaultOpen?: boolean }[]` | - | `defaultOpen: 5.11.0` | | placement | Placement of popup | `top` \| `topLeft` \| `topRight` \| `bottom` \| `bottomLeft` \| `bottomRight` | `bottomLeft` | | | panelRender | Custom Render Panel | `(panel: React.ReactNode, extra: { components: { Picker: FC; Presets: FC } }) => React.ReactNode` | - | 5.7.0 | | showText | Show color text | boolean \| `(color: Color) => React.ReactNode` | - | 5.7.0 | diff --git a/components/color-picker/index.zh-CN.md b/components/color-picker/index.zh-CN.md index 23a6dfd3a9..867481239f 100644 --- a/components/color-picker/index.zh-CN.md +++ b/components/color-picker/index.zh-CN.md @@ -54,7 +54,7 @@ group: | destroyTooltipOnHide | 关闭后是否销毁弹窗 | `boolean` | false | 5.7.0 | | format | 颜色格式 | `rgb` \| `hex` \| `hsb` | `hex` | | | open | 是否显示弹出窗口 | boolean | - | | -| presets | 预设的颜色 | `{ label: ReactNode, colors: Array, defaultCollapsed?: boolean }[]` | - | `defaultCollapsed: 5.11.0` | +| presets | 预设的颜色 | `{ label: ReactNode, colors: Array, defaultOpen?: boolean }[]` | - | `defaultOpen: 5.11.0` | | placement | 弹出窗口的位置 | `top` \| `topLeft` \| `topRight` \| `bottom` \| `bottomLeft` \| `bottomRight` | `bottomLeft` | | | panelRender | 自定义渲染面板 | `(panel: React.ReactNode, extra: { components: { Picker: FC; Presets: FC } }) => React.ReactNode` | - | 5.7.0 | | showText | 显示颜色文本 | boolean \| `(color: Color) => React.ReactNode` | - | 5.7.0 | diff --git a/components/color-picker/interface.ts b/components/color-picker/interface.ts index 2b300f3b0d..f56f5eb693 100644 --- a/components/color-picker/interface.ts +++ b/components/color-picker/interface.ts @@ -14,8 +14,9 @@ export interface PresetsItem { /** * Whether the initial state is collapsed * @since 5.11.0 + * @default true */ - defaultCollapsed?: boolean; + defaultOpen?: boolean; } export type TriggerType = 'click' | 'hover';