Browse Source

feat: Dropdown support autoAdjustOverflow (#39741)

* feat: Dropdown support autoAdjustOverflow (#39735)

* feat: Dropdown support autoAdjustOverflow

* docs: api

* docs: update api desc

* docs: update
pull/39813/head
MadCcc 2 years ago
committed by GitHub
parent
commit
62cefcae89
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      components/dropdown/dropdown.tsx
  2. 1
      components/dropdown/index.en-US.md
  3. 1
      components/dropdown/index.zh-CN.md

5
components/dropdown/dropdown.tsx

@ -8,6 +8,7 @@ import Menu from '../menu';
import type { MenuProps } from '../menu';
import { ConfigContext } from '../config-provider';
import { OverrideProvider } from '../menu/OverrideContext';
import type { AdjustOverflow } from '../_util/placements';
import getPlacements from '../_util/placements';
import { cloneElement } from '../_util/reactNode';
import { tuple } from '../_util/type';
@ -70,6 +71,7 @@ export interface DropdownProps {
mouseLeaveDelay?: number;
openClassName?: string;
children?: React.ReactNode;
autoAdjustOverflow?: boolean | AdjustOverflow;
// Deprecated
/** @deprecated Please use `menu` instead */
@ -158,6 +160,7 @@ const Dropdown: DropdownInterface = (props) => {
onOpenChange,
mouseEnterDelay = 0.15,
mouseLeaveDelay = 0.1,
autoAdjustOverflow = true,
} = props;
const prefixCls = getPrefixCls('dropdown', customizePrefixCls);
@ -198,7 +201,7 @@ const Dropdown: DropdownInterface = (props) => {
const builtinPlacements = getPlacements({
arrowPointAtCenter: typeof arrow === 'object' && arrow.pointAtCenter,
autoAdjustOverflow: true,
autoAdjustOverflow,
});
const onMenuClick = React.useCallback(() => {

1
components/dropdown/index.en-US.md

@ -51,6 +51,7 @@ return (
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| arrow | Whether the dropdown arrow should be visible | boolean \| { pointAtCenter: boolean } | false | |
| autoAdjustOverflow | Whether to adjust dropdown placement automatically when dropdown is off screen | boolean | true | >= 4.24.5 < 5.0.0 \|\| >= 5.2.0 |
| autoFocus | Focus element in `overlay` when opened | boolean | false | 4.21.0 |
| disabled | Whether the dropdown menu is disabled | boolean | - | |
| destroyPopupOnHide | Whether destroy dropdown when hidden | boolean | false | |

1
components/dropdown/index.zh-CN.md

@ -55,6 +55,7 @@ return (
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| arrow | 下拉框箭头是否显示 | boolean \| { pointAtCenter: boolean } | false | |
| autoAdjustOverflow | 下拉框被遮挡时自动调整位置 | boolean | true | >= 4.24.5 < 5.0.0 \|\| >= 5.2.0 |
| autoFocus | 打开后自动聚焦下拉框 | boolean | false | 4.21.0 |
| disabled | 菜单是否禁用 | boolean | - | |
| destroyPopupOnHide | 关闭后是否销毁 Dropdown | boolean | false | |

Loading…
Cancel
Save