mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 01:29:11 +08:00
feat: Dropdown support autoAdjustOverflow (#39741)
* feat: Dropdown support autoAdjustOverflow (#39735) * feat: Dropdown support autoAdjustOverflow * docs: api * docs: update api desc * docs: update
This commit is contained in:
parent
dc6a26f201
commit
62cefcae89
@ -8,6 +8,7 @@ import Menu from '../menu';
|
|||||||
import type { MenuProps } from '../menu';
|
import type { MenuProps } from '../menu';
|
||||||
import { ConfigContext } from '../config-provider';
|
import { ConfigContext } from '../config-provider';
|
||||||
import { OverrideProvider } from '../menu/OverrideContext';
|
import { OverrideProvider } from '../menu/OverrideContext';
|
||||||
|
import type { AdjustOverflow } from '../_util/placements';
|
||||||
import getPlacements from '../_util/placements';
|
import getPlacements from '../_util/placements';
|
||||||
import { cloneElement } from '../_util/reactNode';
|
import { cloneElement } from '../_util/reactNode';
|
||||||
import { tuple } from '../_util/type';
|
import { tuple } from '../_util/type';
|
||||||
@ -70,6 +71,7 @@ export interface DropdownProps {
|
|||||||
mouseLeaveDelay?: number;
|
mouseLeaveDelay?: number;
|
||||||
openClassName?: string;
|
openClassName?: string;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
|
autoAdjustOverflow?: boolean | AdjustOverflow;
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
/** @deprecated Please use `menu` instead */
|
/** @deprecated Please use `menu` instead */
|
||||||
@ -158,6 +160,7 @@ const Dropdown: DropdownInterface = (props) => {
|
|||||||
onOpenChange,
|
onOpenChange,
|
||||||
mouseEnterDelay = 0.15,
|
mouseEnterDelay = 0.15,
|
||||||
mouseLeaveDelay = 0.1,
|
mouseLeaveDelay = 0.1,
|
||||||
|
autoAdjustOverflow = true,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const prefixCls = getPrefixCls('dropdown', customizePrefixCls);
|
const prefixCls = getPrefixCls('dropdown', customizePrefixCls);
|
||||||
@ -198,7 +201,7 @@ const Dropdown: DropdownInterface = (props) => {
|
|||||||
|
|
||||||
const builtinPlacements = getPlacements({
|
const builtinPlacements = getPlacements({
|
||||||
arrowPointAtCenter: typeof arrow === 'object' && arrow.pointAtCenter,
|
arrowPointAtCenter: typeof arrow === 'object' && arrow.pointAtCenter,
|
||||||
autoAdjustOverflow: true,
|
autoAdjustOverflow,
|
||||||
});
|
});
|
||||||
|
|
||||||
const onMenuClick = React.useCallback(() => {
|
const onMenuClick = React.useCallback(() => {
|
||||||
|
@ -51,6 +51,7 @@ return (
|
|||||||
| Property | Description | Type | Default | Version |
|
| Property | Description | Type | Default | Version |
|
||||||
| --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
| arrow | Whether the dropdown arrow should be visible | boolean \| { pointAtCenter: boolean } | false | |
|
| 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 |
|
| autoFocus | Focus element in `overlay` when opened | boolean | false | 4.21.0 |
|
||||||
| disabled | Whether the dropdown menu is disabled | boolean | - | |
|
| disabled | Whether the dropdown menu is disabled | boolean | - | |
|
||||||
| destroyPopupOnHide | Whether destroy dropdown when hidden | boolean | false | |
|
| destroyPopupOnHide | Whether destroy dropdown when hidden | boolean | false | |
|
||||||
|
@ -55,6 +55,7 @@ return (
|
|||||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||||
| --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
| arrow | 下拉框箭头是否显示 | boolean \| { pointAtCenter: boolean } | false | |
|
| arrow | 下拉框箭头是否显示 | boolean \| { pointAtCenter: boolean } | false | |
|
||||||
|
| autoAdjustOverflow | 下拉框被遮挡时自动调整位置 | boolean | true | >= 4.24.5 < 5.0.0 \|\| >= 5.2.0 |
|
||||||
| autoFocus | 打开后自动聚焦下拉框 | boolean | false | 4.21.0 |
|
| autoFocus | 打开后自动聚焦下拉框 | boolean | false | 4.21.0 |
|
||||||
| disabled | 菜单是否禁用 | boolean | - | |
|
| disabled | 菜单是否禁用 | boolean | - | |
|
||||||
| destroyPopupOnHide | 关闭后是否销毁 Dropdown | boolean | false | |
|
| destroyPopupOnHide | 关闭后是否销毁 Dropdown | boolean | false | |
|
||||||
|
Loading…
Reference in New Issue
Block a user