From 3073cf188d04538ecd036e807edc6007b537b297 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Thu, 29 Jan 2026 11:09:01 +0700 Subject: [PATCH] docs: Why can't the Segmented be disabled? (#56786) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: add Why can't Segmented be disabled * Update components/form/index.en-US.md Signed-off-by: thinkasany <480968828@qq.com> * Update components/form/index.en-US.md Signed-off-by: thinkasany <480968828@qq.com> * Apply suggestion from @meet-student Signed-off-by: 遇见同学 <1875694521@qq.com> * Apply suggestion from @meet-student Signed-off-by: 遇见同学 <1875694521@qq.com> * docs: update faq * Update components/form/__tests__/index.test.tsx Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: 二货爱吃白萝卜 --------- Signed-off-by: thinkasany <480968828@qq.com> Signed-off-by: 遇见同学 <1875694521@qq.com> Signed-off-by: 二货爱吃白萝卜 Co-authored-by: 遇见同学 <1875694521@qq.com> Co-authored-by: 二货机器人 Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- components/form/__tests__/index.test.tsx | 15 +++++++++++++++ components/form/index.en-US.md | 4 ++++ components/form/index.zh-CN.md | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/components/form/__tests__/index.test.tsx b/components/form/__tests__/index.test.tsx index d12494d411..0e234a54a8 100644 --- a/components/form/__tests__/index.test.tsx +++ b/components/form/__tests__/index.test.tsx @@ -28,6 +28,7 @@ import Select from '../../select'; import Slider from '../../slider'; import Switch from '../../switch'; import Popover from '../../popover'; +import Segmented from '../../segmented'; import TreeSelect from '../../tree-select'; import Upload from '../../upload'; import type { NamePath } from '../interface'; @@ -1378,6 +1379,20 @@ describe('Form', () => { expect(container.firstChild).toMatchSnapshot(); }); + // https://github.com/ant-design/ant-design/pull/54749#issuecomment-3797737096 + it('Segmented should not be disabled even Form is disabled', () => { + const { container } = render( +
+ + + +
, + ); + expect(container.querySelector('.ant-segmented')).not.toHaveClass( + 'ant-segmented-disabled', + ); + }); + it('form.item should support layout', () => { const App: React.FC = () => (
diff --git a/components/form/index.en-US.md b/components/form/index.en-US.md index 8a98420e3b..51df8e77b6 100644 --- a/components/form/index.en-US.md +++ b/components/form/index.en-US.md @@ -578,6 +578,10 @@ type Rule = RuleConfig | ((form: FormInstance) => RuleConfig); ## FAQ +### Why can't Segmented be disabled by Form `disabled`? {#faq-segmented-cannot-disabled} + +Segmented is designed as a data display component, not a form control component. Although it can be used as a form control similar to Radio, it was not designed for this purpose. Therefore, its behavior is more similar to the Tabs component and will not be disabled by Form's `disabled` prop. For related discussions, see [#54749](https://github.com/ant-design/ant-design/pull/54749#issuecomment-3797737096). + ### Why can't Switch, Checkbox bind data? {#faq-switch-checkbox-binding} Form.Item default bind value to `value` prop, but Switch or Checkbox value prop is `checked`. You can use `valuePropName` to change bind value prop. diff --git a/components/form/index.zh-CN.md b/components/form/index.zh-CN.md index bff6e3d55c..8a01ed0235 100644 --- a/components/form/index.zh-CN.md +++ b/components/form/index.zh-CN.md @@ -577,6 +577,10 @@ type Rule = RuleConfig | ((form: FormInstance) => RuleConfig); ## FAQ +### Segmented 为什么不能被 Form `disabled` 禁用? {#faq-segmented-cannot-disabled} + +Segmented 设计上为数据展示类组件,而非表单控件组件。虽然它可以作为类似 Radio 的表单控件使用,但并非为此设计。因而行为上更类似于 Tabs 组件,不会被 Form 的 `disabled` 所禁用。相关讨论参考 [#54749](https://github.com/ant-design/ant-design/pull/54749#issuecomment-3797737096)。 + ### Switch、Checkbox 为什么不能绑定数据? {#faq-switch-checkbox-binding} Form.Item 默认绑定值属性到 `value` 上,而 Switch、Checkbox 等组件的值属性为 `checked`。你可以通过 `valuePropName` 来修改绑定的值属性。