mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
feat: improve prop def for tooltip
This commit is contained in:
parent
69b0cc1a10
commit
b029e38705
@ -42,11 +42,12 @@ export default class MenuItem extends React.Component<MenuItemProps> {
|
||||
return (
|
||||
<MenuContext.Consumer>
|
||||
{({ inlineCollapsed }: MenuContextProps) => {
|
||||
const tooltipProps: TooltipProps = {};
|
||||
const tooltipProps: TooltipProps = {
|
||||
title: title || (level === 1 ? children : ''),
|
||||
};
|
||||
|
||||
let titleNode = title || (level === 1 ? children : '');
|
||||
if (!siderCollapsed && !inlineCollapsed) {
|
||||
titleNode = null;
|
||||
tooltipProps.title = null;
|
||||
// Reset `visible` to fix control mode tooltip display not correct
|
||||
// ref: https://github.com/ant-design/ant-design/issues/16742
|
||||
tooltipProps.visible = false;
|
||||
@ -55,7 +56,6 @@ export default class MenuItem extends React.Component<MenuItemProps> {
|
||||
return (
|
||||
<Tooltip
|
||||
{...tooltipProps}
|
||||
title={titleNode}
|
||||
placement="right"
|
||||
overlayClassName={`${rootPrefixCls}-inline-collapsed-tooltip`}
|
||||
>
|
||||
|
@ -64,11 +64,18 @@ export interface AbstractTooltipProps {
|
||||
|
||||
export type RenderFunction = () => React.ReactNode;
|
||||
|
||||
export interface TooltipProps extends AbstractTooltipProps {
|
||||
interface TooltipPropsWithOverlay extends AbstractTooltipProps {
|
||||
title?: React.ReactNode | RenderFunction;
|
||||
overlay: React.ReactNode | RenderFunction;
|
||||
}
|
||||
|
||||
interface TooltipPropsWithTitle extends AbstractTooltipProps {
|
||||
title: React.ReactNode | RenderFunction;
|
||||
overlay?: React.ReactNode | RenderFunction;
|
||||
}
|
||||
|
||||
export declare type TooltipProps = TooltipPropsWithTitle | TooltipPropsWithOverlay;
|
||||
|
||||
const splitObject = (obj: any, keys: string[]) => {
|
||||
const picked: any = {};
|
||||
const omitted: any = { ...obj };
|
||||
|
Loading…
Reference in New Issue
Block a user