mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 10:06:22 +00:00
fix: should only show one scroll bar in drop-down menu (#2231)
This commit is contained in:
parent
c20c68cc42
commit
20a7e9a657
@ -1,4 +1,3 @@
|
|||||||
import { css } from '@emotion/css';
|
|
||||||
import { ISchema, observer, useForm } from '@formily/react';
|
import { ISchema, observer, useForm } from '@formily/react';
|
||||||
import { error, isString } from '@nocobase/utils/client';
|
import { error, isString } from '@nocobase/utils/client';
|
||||||
import { Button, Dropdown, MenuProps, Switch } from 'antd';
|
import { Button, Dropdown, MenuProps, Switch } from 'antd';
|
||||||
@ -17,13 +16,6 @@ import {
|
|||||||
SchemaInitializerItemProps,
|
SchemaInitializerItemProps,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
const overlayClassName = css`
|
|
||||||
.ant-dropdown-menu-item-group-list {
|
|
||||||
max-height: 40vh;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const defaultWrap = (s: ISchema) => s;
|
const defaultWrap = (s: ISchema) => s;
|
||||||
|
|
||||||
export const SchemaInitializerItemContext = createContext(null);
|
export const SchemaInitializerItemContext = createContext(null);
|
||||||
@ -156,7 +148,7 @@ SchemaInitializer.Button = observer(
|
|||||||
key: item.key || `item-group-${indexA}`,
|
key: item.key || `item-group-${indexA}`,
|
||||||
label,
|
label,
|
||||||
title: label,
|
title: label,
|
||||||
popupClassName: styles.nbMenuItemGroup,
|
popupClassName: styles.nbMenuItemSubMenu,
|
||||||
children: renderItems(item.children),
|
children: renderItems(item.children),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -175,7 +167,6 @@ SchemaInitializer.Button = observer(
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
className={classNames('nb-schema-initializer-button')}
|
className={classNames('nb-schema-initializer-button')}
|
||||||
openClassName={`nb-schema-initializer-button-open`}
|
openClassName={`nb-schema-initializer-button-open`}
|
||||||
overlayClassName={classNames('nb-schema-initializer-button-overlay', overlayClassName)}
|
|
||||||
open={visible}
|
open={visible}
|
||||||
onOpenChange={(open) => {
|
onOpenChange={(open) => {
|
||||||
// 如果不清空输入框的值,那么下次打开的时候会出现上次输入的值
|
// 如果不清空输入框的值,那么下次打开的时候会出现上次输入的值
|
||||||
@ -184,7 +175,7 @@ SchemaInitializer.Button = observer(
|
|||||||
}}
|
}}
|
||||||
menu={{
|
menu={{
|
||||||
style: {
|
style: {
|
||||||
maxHeight: '60vh',
|
maxHeight: '50vh',
|
||||||
overflowY: 'auto',
|
overflowY: 'auto',
|
||||||
},
|
},
|
||||||
items: menuItems.current,
|
items: menuItems.current,
|
||||||
|
@ -5,6 +5,11 @@ export const useStyles = createStyles(({ token }) => {
|
|||||||
nbMenuItemGroup: {
|
nbMenuItemGroup: {
|
||||||
maxHeight: '50vh',
|
maxHeight: '50vh',
|
||||||
overflowY: 'auto',
|
overflowY: 'auto',
|
||||||
|
},
|
||||||
|
|
||||||
|
nbMenuItemSubMenu: {
|
||||||
|
maxHeight: '50vh',
|
||||||
|
overflowY: 'auto',
|
||||||
boxShadow: token.boxShadowSecondary,
|
boxShadow: token.boxShadowSecondary,
|
||||||
borderRadius: token.borderRadiusLG,
|
borderRadius: token.borderRadiusLG,
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { css } from '@emotion/css';
|
|
||||||
import { ArrayCollapse, ArrayItems, FormDialog, FormItem, FormLayout, Input } from '@formily/antd-v5';
|
import { ArrayCollapse, ArrayItems, FormDialog, FormItem, FormLayout, Input } from '@formily/antd-v5';
|
||||||
import { Field, GeneralField, createForm } from '@formily/core';
|
import { Field, GeneralField, createForm } from '@formily/core';
|
||||||
import { ISchema, Schema, SchemaOptionsContext, useField, useFieldSchema, useForm } from '@formily/react';
|
import { ISchema, Schema, SchemaOptionsContext, useField, useFieldSchema, useForm } from '@formily/react';
|
||||||
@ -18,7 +17,6 @@ import {
|
|||||||
Space,
|
Space,
|
||||||
Switch,
|
Switch,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import classNames from 'classnames';
|
|
||||||
import _, { cloneDeep } from 'lodash';
|
import _, { cloneDeep } from 'lodash';
|
||||||
import React, {
|
import React, {
|
||||||
ReactNode,
|
ReactNode,
|
||||||
@ -131,16 +129,6 @@ export const SchemaSettingsProvider: React.FC<SchemaSettingsProviderProps> = (pr
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const overlayClassName = classNames(
|
|
||||||
'nb-schema-initializer-button-overlay',
|
|
||||||
css`
|
|
||||||
.ant-dropdown-menu-item-group-list {
|
|
||||||
max-height: 40vh;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
);
|
|
||||||
|
|
||||||
export const SchemaSettings: React.FC<SchemaSettingsProps> & SchemaSettingsNested = (props) => {
|
export const SchemaSettings: React.FC<SchemaSettingsProps> & SchemaSettingsNested = (props) => {
|
||||||
const { title, dn, ...others } = props;
|
const { title, dn, ...others } = props;
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
@ -165,7 +153,6 @@ export const SchemaSettings: React.FC<SchemaSettingsProps> & SchemaSettingsNeste
|
|||||||
changeMenu(open);
|
changeMenu(open);
|
||||||
}}
|
}}
|
||||||
menu={{ items }}
|
menu={{ items }}
|
||||||
overlayClassName={overlayClassName}
|
|
||||||
>
|
>
|
||||||
{typeof title === 'string' ? <span>{title}</span> : title}
|
{typeof title === 'string' ? <span>{title}</span> : title}
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
Loading…
Reference in New Issue
Block a user