From 490b327345205acf5603e2e24ba5285fd67a5d9e Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Thu, 25 Apr 2024 11:41:15 +0800 Subject: [PATCH] fix(dropdown): fix Dropdown children Penetrate disabled (#2862) * fix(dropdown): fix Dropdown children Penetrate disabled * 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 e5804da67..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} > - {arrayChildren?.[0]} + {dropDownTrigger} ); };