<commit_before>import * as React from 'react';
import { Item } from 'rc-menu';
import { ClickParam } from '.';
import { MenuContext, MenuContextProps } from './';
import Tooltip from '../tooltip';
import { SiderContext, SiderContextProps } from '../layout/Sider';

export interface MenuItemProps {
  rootPrefixCls?: string;
  disabled?: boolean;
  level?: number;
  title?: React.ReactNode;
  children?: React.ReactNode;
  className?: string;
  style?: React.CSSProperties;
  onClick?: (param: ClickParam) => void;
  onMouseEnter?: (e: { key: string; domEvent: MouseEvent }) => void;
  onMouseLeave?: (e: { key: string; domEvent: MouseEvent }) => void;
}

export default class MenuItem extends React.Component<MenuItemProps> {
  static isMenuItem = true;
  private menuItem: this;

  onKeyDown = (e: React.MouseEvent<HTMLElement>) => {
    this.menuItem.onKeyDown(e);
  };

  saveMenuItem = (menuItem: this) => {
    this.menuItem = menuItem;
  };

  renderItem = ({ siderCollapsed }: SiderContextProps) => {
    const { level, children, rootPrefixCls } = this.props;
    const { title, ...rest } = this.props;

    return (
      <MenuContext.Consumer>
        {({ inlineCollapsed }: MenuContextProps) => {
          let titleNode = title || (level === 1 ? children : '');
          if (!siderCollapsed && !inlineCollapsed) {
            titleNode = null;
          }

          return (
            <Tooltip
              title={titleNode}
              placement="right"
              overlayClassName={`${rootPrefixCls}-inline-collapsed-tooltip`}
            >
              <Item {...rest} title={title} ref={this.saveMenuItem} />
            </Tooltip>
          );
        }}
      </MenuContext.Consumer>
    );
  };
<commit_msg>fix: Tooltip not hidden when menu is in control mode (#16812)<commit_after>import * as React from 'react';
import { Item } from 'rc-menu';
import { ClickParam } from '.';
import { MenuContext, MenuContextProps } from './';
import Tooltip, { TooltipProps } from '../tooltip';
import { SiderContext, SiderContextProps } from '../layout/Sider';

export interface MenuItemProps {
  rootPrefixCls?: string;
  disabled?: boolean;
  level?: number;
  title?: React.ReactNode;
  children?: React.ReactNode;
  className?: string;
  style?: React.CSSProperties;
  onClick?: (param: ClickParam) => void;
  onMouseEnter?: (e: { key: string; domEvent: MouseEvent }) => void;
  onMouseLeave?: (e: { key: string; domEvent: MouseEvent }) => void;
}

export default class MenuItem extends React.Component<MenuItemProps> {
  static isMenuItem = true;
  private menuItem: this;

  onKeyDown = (e: React.MouseEvent<HTMLElement>) => {
    this.menuItem.onKeyDown(e);
  };

  saveMenuItem = (menuItem: this) => {
    this.menuItem = menuItem;
  };

  renderItem = ({ siderCollapsed }: SiderContextProps) => {
    const { level, children, rootPrefixCls } = this.props;
    const { title, ...rest } = this.props;

    return (
      <MenuContext.Consumer>
        {({ inlineCollapsed }: MenuContextProps) => {
          const tooltipProps: TooltipProps = {};

          let titleNode = title || (level === 1 ? children : '');
          if (!siderCollapsed && !inlineCollapsed) {
            titleNode = null;
            // Reset `visible` to fix control mode tooltip display not correct
            // ref: https://github.com/ant-design/ant-design/issues/16742
            tooltipProps.visible = false;
          }

          return (
            <Tooltip
              {...tooltipProps}
              title={titleNode}
              placement="right"
              overlayClassName={`${rootPrefixCls}-inline-collapsed-tooltip`}
            >
              <Item {...rest} title={title} ref={this.saveMenuItem} />
            </Tooltip>
          );
        }}
      </MenuContext.Consumer>
    );
  };

{'fraction_non_alphanumeric': 0.14121037463976946, 'fraction_numerical': 0.003143830233167409, 'mean_word_length': 2.632730732635585, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 31, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4304657', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1107, 'n_words': 267}