Skip to content

Commit

Permalink
feat: ConfigProvider support config popupOverflow for scroll logic (a…
Browse files Browse the repository at this point in the history
…nt-design#41676)

* feat: popupOverflow

* test: add test case

* docs: preview

* docs: update preview

* test: update test case
  • Loading branch information
zombieJ authored and RedJue committed Apr 25, 2023
1 parent 75d713c commit 1564dfd
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 3,563 deletions.
50 changes: 50 additions & 0 deletions .dumi/theme/builtins/InlinePopover/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { PictureOutlined } from '@ant-design/icons';
import { Image, Tooltip, Typography } from 'antd';
import React from 'react';
import useLocale from '../../../hooks/useLocale';

const locales = {
cn: {
tip: '预览',
},
en: {
tip: 'Preview',
},
};

export interface InlinePopoverProps {
previewURL?: string;
}

// 鼠标悬浮弹出 Popover 组件,用于帮助用户更快看到一些属性对应的预览效果
const InlinePopover: React.FC = (props: InlinePopoverProps) => {
const { previewURL } = props;

const [locale] = useLocale(locales);
const [visible, setVisible] = React.useState(false);

return (
<>
<Tooltip title={locale.tip}>
<Typography.Link onClick={() => setVisible(true)}>
<PictureOutlined />
</Typography.Link>
</Tooltip>

<Image
width={10}
style={{ display: 'none' }}
src={previewURL}
preview={{
visible,
src: previewURL,
onVisibleChange: (value) => {
setVisible(value);
},
}}
/>
</>
);
};

export default InlinePopover;
5 changes: 2 additions & 3 deletions components/cascader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ const Cascader = React.forwardRef((props: CascaderProps<any>, ref: React.Ref<Cas
getPrefixCls,
renderEmpty,
direction: rootDirection,
// virtual,
// dropdownMatchSelectWidth,
popupOverflow,
} = React.useContext(ConfigContext);

const mergedDirection = direction || rootDirection;
Expand Down Expand Up @@ -276,7 +275,7 @@ const Cascader = React.forwardRef((props: CascaderProps<any>, ref: React.Ref<Cas
return isRtl ? 'bottomRight' : 'bottomLeft';
}, [placement, isRtl]);

const mergedBuiltinPlacements = useBuiltinPlacements(builtinPlacements);
const mergedBuiltinPlacements = useBuiltinPlacements(builtinPlacements, popupOverflow);

// ==================== Render =====================
const renderNode = (
Expand Down
Loading

0 comments on commit 1564dfd

Please sign in to comment.