From 4d8cdcf0cd7495b5bcff62397fbd1f03cb0ad56e Mon Sep 17 00:00:00 2001 From: HaixingOoO <974758671@qq.com> Date: Wed, 24 Apr 2024 21:37:13 +0800 Subject: [PATCH 1/2] fix(dropdown): fix Dropdown children Penetrate disabled --- src/dropdown/Dropdown.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dropdown/Dropdown.tsx b/src/dropdown/Dropdown.tsx index e5804da67..083b286e4 100644 --- a/src/dropdown/Dropdown.tsx +++ b/src/dropdown/Dropdown.tsx @@ -74,7 +74,7 @@ const Dropdown: React.FC & { onVisibleChange={handleVisibleChange} {...popupParams} > - {arrayChildren?.[0]} + {React.cloneElement(arrayChildren?.[0] as React.ReactElement, { disabled })} ); }; From 8b871e400f0713b6e12ecda7e66a7eaffbf47960 Mon Sep 17 00:00:00 2001 From: HaixingOoO <974758671@qq.com> Date: Wed, 24 Apr 2024 22:01:57 +0800 Subject: [PATCH 2/2] fix(dropdown): fix test --- src/dropdown/Dropdown.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dropdown/Dropdown.tsx b/src/dropdown/Dropdown.tsx index 083b286e4..06bbe046a 100644 --- a/src/dropdown/Dropdown.tsx +++ b/src/dropdown/Dropdown.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { isValidElement, useState } from 'react'; import classNames from 'classnames'; import omit from 'lodash/omit'; import { DropdownOption, TdDropdownProps } from './type'; @@ -66,6 +66,9 @@ const Dropdown: React.FC & { overlayInnerStyle: style, }; + const child = arrayChildren?.[0]; + const dropDownTrigger = isValidElement(child) ? React.cloneElement(child as React.ReactElement, { disabled }) : child; + return ( & { onVisibleChange={handleVisibleChange} {...popupParams} > - {React.cloneElement(arrayChildren?.[0] as React.ReactElement, { disabled })} + {dropDownTrigger} ); };