fix: dropdownMatchSelectWidth=false (#2143)

This commit is contained in:
chenos 2023-06-28 10:13:35 +08:00 committed by GitHub
parent 884b265420
commit c229d837a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 105 additions and 61 deletions

View File

@ -84,6 +84,7 @@ export const StrategyActions = connect((props) => {
render: (scope, action) => render: (scope, action) =>
!action.onNewRecord && ( !action.onNewRecord && (
<Select <Select
dropdownMatchSelectWidth={false}
size={'small'} size={'small'}
value={scope} value={scope}
options={[ options={[

View File

@ -45,6 +45,7 @@ export const ThroughForeignKey = observer(
<div> <div>
<Select <Select
allowClear allowClear
dropdownMatchSelectWidth={false}
placeholder={'留空时,自动生成 FK 字段'} placeholder={'留空时,自动生成 FK 字段'}
disabled={field.disabled} disabled={field.disabled}
value={field.value} value={field.value}
@ -72,6 +73,7 @@ export const TargetForeignKey = observer(
<div> <div>
<Select <Select
allowClear allowClear
dropdownMatchSelectWidth={false}
placeholder={'留空时,自动生成 FK 字段'} placeholder={'留空时,自动生成 FK 字段'}
disabled={field.disabled} disabled={field.disabled}
value={field.value} value={field.value}
@ -100,6 +102,7 @@ export const SourceCollection = observer(
<div> <div>
<Select <Select
disabled disabled
dropdownMatchSelectWidth={false}
value={collection.name} value={collection.name}
options={[{ value: collection.name, label: compile(collection.title) }]} options={[{ value: collection.name, label: compile(collection.title) }]}
/> />

View File

@ -123,6 +123,7 @@ const PreviewCom = (props) => {
) : ( ) : (
<Select <Select
defaultValue={text} defaultValue={text}
dropdownMatchSelectWidth={false}
style={{ width: '100%' }} style={{ width: '100%' }}
options={ options={
item?.possibleTypes.map((v) => { item?.possibleTypes.map((v) => {
@ -148,6 +149,7 @@ const PreviewCom = (props) => {
<Select <Select
defaultValue={text} defaultValue={text}
style={{ width: '100%' }} style={{ width: '100%' }}
dropdownMatchSelectWidth={false}
onChange={(value) => { onChange={(value) => {
const interfaceConfig = getInterface(value); const interfaceConfig = getInterface(value);
handleFieldChange({ ...item, interface: value, uiSchema: interfaceConfig?.default?.uiSchema }, index); handleFieldChange({ ...item, interface: value, uiSchema: interfaceConfig?.default?.uiSchema }, index);

View File

@ -1,4 +1,4 @@
import { RecursionField, observer, useField, useFieldSchema } from '@formily/react'; import { observer, RecursionField, useField, useFieldSchema } from '@formily/react';
import { Input, Select } from 'antd'; import { Input, Select } from 'antd';
import { differenceBy, unionBy } from 'lodash'; import { differenceBy, unionBy } from 'lodash';
import React, { useContext, useMemo, useState } from 'react'; import React, { useContext, useMemo, useState } from 'react';
@ -133,6 +133,7 @@ export const InternalPicker = observer(
<div style={{ width: '100%' }}> <div style={{ width: '100%' }}>
<Select <Select
style={{ width: '100%' }} style={{ width: '100%' }}
dropdownMatchSelectWidth={false}
{...others} {...others}
mode={multiple ? 'multiple' : props.mode} mode={multiple ? 'multiple' : props.mode}
fieldNames={fieldNames} fieldNames={fieldNames}

View File

@ -15,7 +15,7 @@ export const ViewSelect = observer(
} = useContext(CalendarToolbarContext); } = useContext(CalendarToolbarContext);
return ( return (
<div className="ant-btn-group"> <div className="ant-btn-group">
<Select value={view} onChange={onView}> <Select dropdownMatchSelectWidth={false} value={view} onChange={onView}>
{views.map((name) => ( {views.map((name) => (
<Select.Option key={name} value={name}> <Select.Option key={name} value={name}>
{messages[name]} {messages[name]}

View File

@ -31,6 +31,7 @@ export const CollectionSelect = connect(
return ( return (
<Select <Select
placeholder={t('Select collection')} placeholder={t('Select collection')}
dropdownMatchSelectWidth={false}
{...others} {...others}
showSearch showSearch
filterOption={(input, option) => (option?.label ?? '').includes(input)} filterOption={(input, option) => (option?.label ?? '').includes(input)}
@ -39,7 +40,8 @@ export const CollectionSelect = connect(
); );
}, },
mapReadPretty( mapReadPretty(
observer((props: CollectionSelectProps) => { observer(
(props: CollectionSelectProps) => {
const { mode } = props; const { mode } = props;
const compile = useCompile(); const compile = useCompile();
const options = useOptions(props).filter((option) => { const options = useOptions(props).filter((option) => {
@ -58,6 +60,8 @@ export const CollectionSelect = connect(
))} ))}
</div> </div>
); );
}, { displayName: 'CollectionSelectObserver' }), },
{ displayName: 'CollectionSelectObserver' },
),
), ),
); );

View File

@ -1,10 +1,10 @@
import React, { useEffect, useMemo, useState } from 'react';
import { Select, SelectProps } from 'antd';
import Cron from './Cron';
import { connect, mapReadPretty, useFieldSchema } from '@formily/react'; import { connect, mapReadPretty, useFieldSchema } from '@formily/react';
import { Select, SelectProps } from 'antd';
import React, { useEffect, useMemo, useState } from 'react';
import { useCollection } from '../../../collection-manager'; import { useCollection } from '../../../collection-manager';
import { useCompile } from '../../hooks'; import { useCompile } from '../../hooks';
import { EllipsisWithTooltip } from '../input'; import { EllipsisWithTooltip } from '../input';
import Cron from './Cron';
interface CronSetProps extends SelectProps { interface CronSetProps extends SelectProps {
onChange: (v: string) => void; onChange: (v: string) => void;
@ -63,7 +63,14 @@ const CronSetInternal = (props: CronSetProps) => {
return ( return (
<fieldset> <fieldset>
<Select allowClear {...props} value={value} options={options} onChange={(value) => onCronChange(value)}></Select> <Select
dropdownMatchSelectWidth={false}
allowClear
{...props}
value={value}
options={options}
onChange={(value) => onCronChange(value)}
></Select>
{isCustomize ? ( {isCustomize ? (
<Cron <Cron
value={value} value={value}

View File

@ -4,8 +4,8 @@ import { ArrayField, connect, useField } from '@formily/react';
import { Select, Space } from 'antd'; import { Select, Space } from 'antd';
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { Trans, useTranslation } from 'react-i18next'; import { Trans, useTranslation } from 'react-i18next';
import { FilterLogicContext, RemoveConditionContext } from './context';
import { FilterItems } from './FilterItems'; import { FilterItems } from './FilterItems';
import { FilterLogicContext, RemoveConditionContext } from './context';
export const FilterGroup = connect((props) => { export const FilterGroup = connect((props) => {
const { bordered = true, disabled } = props; const { bordered = true, disabled } = props;

View File

@ -40,6 +40,7 @@ export const FilterItem = observer(
className={css` className={css`
min-width: 110px; min-width: 110px;
`} `}
dropdownMatchSelectWidth={false}
value={operator?.value} value={operator?.value}
options={compile(operators)} options={compile(operators)}
onChange={(value) => { onChange={(value) => {

View File

@ -143,6 +143,7 @@ export const Templates = ({ style = {}, form }) => {
{t('Data template')}:{' '} {t('Data template')}:{' '}
</label> </label>
<Select <Select
dropdownMatchSelectWidth={false}
// style={{ width: '8em' }} // style={{ width: '8em' }}
options={templates} options={templates}
fieldNames={{ label: 'title', value: 'key' }} fieldNames={{ label: 'title', value: 'key' }}

View File

@ -178,6 +178,7 @@ export const InputRecordPicker: React.FC<any> = (props: IRecordPickerProps) => {
{...others} {...others}
mode={multiple ? 'multiple' : props.mode} mode={multiple ? 'multiple' : props.mode}
fieldNames={fieldNames} fieldNames={fieldNames}
dropdownMatchSelectWidth={false}
onDropdownVisibleChange={(open) => { onDropdownVisibleChange={(open) => {
setVisible(true); setVisible(true);
}} }}

View File

@ -1,14 +1,12 @@
import { CloseCircleFilled } from '@ant-design/icons'; import { CloseCircleFilled } from '@ant-design/icons';
import { css, cx } from '@emotion/css'; import { css, cx } from '@emotion/css';
import { useForm } from '@formily/react'; import { useForm } from '@formily/react';
import { Input as AntInput, Cascader, DatePicker, InputNumber, Select, Tag } from 'antd';
import moment from 'moment';
import React, { useCallback, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { error } from '@nocobase/utils/client'; import { error } from '@nocobase/utils/client';
import { Input as AntInput, Cascader, DatePicker, InputNumber, Select, Tag } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import { useMemo } from 'react'; import moment from 'moment';
import React, { useCallback, useEffect, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useCompile } from '../..'; import { useCompile } from '../..';
import { Option } from '../../../schema-settings/VariableInput/type'; import { Option } from '../../../schema-settings/VariableInput/type';
import { XButton } from './XButton'; import { XButton } from './XButton';

View File

@ -181,7 +181,13 @@ export const AssignedField = (props: any) => {
return <CollectionField {...props} value={value} onChange={valueChangeHandler} style={{ minWidth: 150 }} />; return <CollectionField {...props} value={value} onChange={valueChangeHandler} style={{ minWidth: 150 }} />;
} else { } else {
return ( return (
<Select defaultValue={fieldType} value={fieldType} style={{ minWidth: 150 }} onChange={fieldTypeChangeHandler}> <Select
dropdownMatchSelectWidth={false}
defaultValue={fieldType}
value={fieldType}
style={{ minWidth: 150 }}
onChange={fieldTypeChangeHandler}
>
{options?.map((opt) => { {options?.map((opt) => {
return ( return (
<Select.Option key={opt.name} value={opt.name}> <Select.Option key={opt.name} value={opt.name}>

View File

@ -172,6 +172,7 @@ function SelectItem(props) {
<div style={{ alignItems: 'center', display: 'flex', justifyContent: 'space-between' }}> <div style={{ alignItems: 'center', display: 'flex', justifyContent: 'space-between' }}>
{title} {title}
<Select <Select
dropdownMatchSelectWidth={false}
bordered={false} bordered={false}
value={value} value={value}
onChange={onChange} onChange={onChange}

View File

@ -72,6 +72,7 @@ export const FormFieldLinkageRuleAction = observer(
placeholder={t('Select field')} placeholder={t('Select field')}
/> />
<Select <Select
dropdownMatchSelectWidth={false}
value={operator} value={operator}
className={css` className={css`
min-width: 120px; min-width: 120px;
@ -121,6 +122,7 @@ export const FormButtonLinkageRuleAction = observer(
<div style={{ marginBottom: 8 }}> <div style={{ marginBottom: 8 }}>
<Space> <Space>
<Select <Select
dropdownMatchSelectWidth={false}
value={operator} value={operator}
options={compile(operators)} options={compile(operators)}
onChange={(value) => { onChange={(value) => {

View File

@ -27,6 +27,7 @@ export const useLanguageSettings = () => {
> >
{t('Language')}{' '} {t('Language')}{' '}
<Select <Select
dropdownMatchSelectWidth={false}
style={{ minWidth: 100 }} style={{ minWidth: 100 }}
bordered={false} bordered={false}
open={open} open={open}

View File

@ -45,6 +45,7 @@ export const useSwitchRole = () => {
<Select <Select
style={{ minWidth: 100 }} style={{ minWidth: 100 }}
bordered={false} bordered={false}
dropdownMatchSelectWidth={false}
fieldNames={{ fieldNames={{
label: 'title', label: 'title',
value: 'name', value: 'name',

View File

@ -25,6 +25,7 @@ export const useThemeSettings = () => {
<Select <Select
style={{ minWidth: 100 }} style={{ minWidth: 100 }}
bordered={false} bordered={false}
dropdownMatchSelectWidth={false}
defaultValue={localStorage.getItem('NOCOBASE_THEME')} defaultValue={localStorage.getItem('NOCOBASE_THEME')}
options={[ options={[
{ label: t('Default theme'), value: 'default' }, { label: t('Default theme'), value: 'default' },

View File

@ -1018,7 +1018,9 @@ export const GraphDrawPage = React.memo(() => {
<div className={cx(collectionListClass)}> <div className={cx(collectionListClass)}>
<SchemaComponent <SchemaComponent
components={{ components={{
Select: (props) => <Select {...props} getPopupContainer={getPopupContainer} />, Select: (props) => (
<Select dropdownMatchSelectWidth={false} {...props} getPopupContainer={getPopupContainer} />
),
AddCollectionAction, AddCollectionAction,
}} }}
schema={{ schema={{

View File

@ -1,14 +1,14 @@
import { observer, useForm } from '@formily/react'; import { observer, useForm } from '@formily/react';
import { action } from '@formily/reactive'; import { action } from '@formily/reactive';
import { import {
useActionContext,
useAPIClient, useAPIClient,
useActionContext,
useCollectionFieldFormValues, useCollectionFieldFormValues,
useCollectionManager, useCollectionManager,
useCompile, useCompile,
useRequest, useRequest,
} from '@nocobase/client'; } from '@nocobase/client';
import { message, Select } from 'antd'; import { Select, message } from 'antd';
import omit from 'lodash/omit'; import omit from 'lodash/omit';
import React, { useContext, useEffect } from 'react'; import React, { useContext, useEffect } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -34,7 +34,12 @@ export const SourceCollection = observer(
const compile = useCompile(); const compile = useCompile();
return ( return (
<div> <div>
<Select disabled value={record.name} options={[{ value: record.name, label: compile(record.title) }]} /> <Select
dropdownMatchSelectWidth={false}
disabled
value={record.name}
options={[{ value: record.name, label: compile(record.title) }]}
/>
</div> </div>
); );
}, },

View File

@ -243,7 +243,9 @@ const PortsCom = React.memo<any>(({ targetGraph, collectionData, setTargetNode,
Input, Input,
Form, Form,
ResourceActionProvider, ResourceActionProvider,
Select: (props) => <Select {...props} getPopupContainer={getPopupContainer} />, Select: (props) => (
<Select dropdownMatchSelectWidth={false} {...props} getPopupContainer={getPopupContainer} />
),
Checkbox, Checkbox,
Radio, Radio,
InputNumber, InputNumber,

View File

@ -85,6 +85,7 @@ const Search = (props: SearchProps) => {
onSearch={onSearch} onSearch={onSearch}
onSelect={onSelect} onSelect={onSelect}
options={options} options={options}
dropdownMatchSelectWidth={false}
></Select> ></Select>
</div> </div>
); );

View File

@ -225,6 +225,7 @@ export const TableTransfer = connect((props) => {
<strong style={{ fontSize: 16 }}>{t('Unshared collections')}</strong> <strong style={{ fontSize: 16 }}>{t('Unshared collections')}</strong>
<Input.Group compact style={{ width: 360 }}> <Input.Group compact style={{ width: 360 }}>
<Select <Select
dropdownMatchSelectWidth={false}
onChange={(value) => { onChange={(value) => {
removedDataSource.setCategoryFilter(value); removedDataSource.setCategoryFilter(value);
}} }}
@ -309,6 +310,7 @@ export const TableTransfer = connect((props) => {
<strong style={{ fontSize: 16 }}>{t('Shared collections')}</strong> <strong style={{ fontSize: 16 }}>{t('Shared collections')}</strong>
<Input.Group compact style={{ width: 360 }}> <Input.Group compact style={{ width: 360 }}>
<Select <Select
dropdownMatchSelectWidth={false}
onChange={(value) => { onChange={(value) => {
addedDataSource.setCategoryFilter(value); addedDataSource.setCategoryFilter(value);
}} }}

View File

@ -1,21 +1,19 @@
import { css } from '@emotion/css'; import { css } from '@emotion/css';
import { ArrayTable, FormButtonGroup, FormDrawer, FormLayout, Submit } from '@formily/antd'; import { ArrayTable, FormButtonGroup, FormDrawer, FormLayout, Submit } from '@formily/antd';
import { onFieldValueChange } from '@formily/core'; import { onFieldValueChange } from '@formily/core';
import { SchemaOptionsContext, useForm, useFormEffects, ISchema } from '@formily/react'; import { ISchema, SchemaOptionsContext, useForm, useFormEffects } from '@formily/react';
import {
Cron,
IField,
SchemaComponent,
SchemaComponentOptions,
interfacesProperties,
useCompile,
} from '@nocobase/client';
import { Button, Select } from 'antd'; import { Button, Select } from 'antd';
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { NAMESPACE, lang } from './locale';
import {
Cron,
SchemaComponent,
SchemaComponentOptions,
useCompile,
interfacesProperties,
IField,
useCollectionField,
} from '@nocobase/client';
import { lang, NAMESPACE } from './locale';
function RuleTypeSelect(props) { function RuleTypeSelect(props) {
const compile = useCompile(); const compile = useCompile();
@ -30,7 +28,7 @@ function RuleTypeSelect(props) {
}); });
return ( return (
<Select {...props}> <Select dropdownMatchSelectWidth={false} {...props}>
{Object.keys(RuleTypes).map((key) => ( {Object.keys(RuleTypes).map((key) => (
<Select.Option key={key} value={key}> <Select.Option key={key} value={key}>
{compile(RuleTypes[key].title)} {compile(RuleTypes[key].title)}

View File

@ -1,7 +1,7 @@
import React from 'react';
import { Select, SelectProps } from 'antd';
import { useTopRecord } from '../interface';
import { useCollectionManager, useCompile } from '@nocobase/client'; import { useCollectionManager, useCompile } from '@nocobase/client';
import { Select, SelectProps } from 'antd';
import React from 'react';
import { useTopRecord } from '../interface';
export type SnapshotOwnerCollectionFieldsSelectProps = Omit<SelectProps, 'options'>; export type SnapshotOwnerCollectionFieldsSelectProps = Omit<SelectProps, 'options'>;
@ -18,5 +18,5 @@ export const useSnapshotOwnerCollectionFields = () => {
export const SnapshotOwnerCollectionFieldsSelect: React.FC<SnapshotOwnerCollectionFieldsSelectProps> = (props) => { export const SnapshotOwnerCollectionFieldsSelect: React.FC<SnapshotOwnerCollectionFieldsSelectProps> = (props) => {
const options = useSnapshotOwnerCollectionFields(); const options = useSnapshotOwnerCollectionFields();
return <Select options={options} {...props} />; return <Select dropdownMatchSelectWidth={false} options={options} {...props} />;
}; };

View File

@ -1,6 +1,6 @@
import React from 'react';
import { InputNumber, Select } from 'antd';
import { css } from '@emotion/css'; import { css } from '@emotion/css';
import { InputNumber, Select } from 'antd';
import React from 'react';
import { lang } from '../locale'; import { lang } from '../locale';
const UnitOptions = [ const UnitOptions = [
@ -29,7 +29,11 @@ export default function ({ value = 60000, onChange }) {
`} `}
> >
<InputNumber min={1} value={quantity} onChange={(v) => onChange(Math.round(v * option.value))} /> <InputNumber min={1} value={quantity} onChange={(v) => onChange(Math.round(v * option.value))} />
<Select value={option.value} onChange={(unit) => onChange(Math.round(quantity * unit))}> <Select
dropdownMatchSelectWidth={false}
value={option.value}
onChange={(unit) => onChange(Math.round(quantity * unit))}
>
{UnitOptions.map((item) => ( {UnitOptions.map((item) => (
<Select.Option key={item.value} value={item.value}> <Select.Option key={item.value} value={item.value}>
{lang(item.label)} {lang(item.label)}

View File

@ -1,10 +1,9 @@
import { observer, useForm } from '@formily/react'; import { observer, useForm } from '@formily/react';
import { useCollectionManager, useCompile } from '@nocobase/client';
import { Select } from 'antd'; import { Select } from 'antd';
import React from 'react'; import React from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useCollectionManager, useCompile } from '@nocobase/client';
export const DateFieldsSelect: React.FC<any> = observer( export const DateFieldsSelect: React.FC<any> = observer(
(props) => { (props) => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -14,7 +13,7 @@ export const DateFieldsSelect: React.FC<any> = observer(
const fields = getCollectionFields(values?.collection); const fields = getCollectionFields(values?.collection);
return ( return (
<Select placeholder={t('Select field')} {...props}> <Select dropdownMatchSelectWidth={false} placeholder={t('Select field')} {...props}>
{fields {fields
.filter((field) => !field.hidden && (field.uiSchema ? field.type === 'date' : false)) .filter((field) => !field.hidden && (field.uiSchema ? field.type === 'date' : false))
.map((field) => ( .map((field) => (