fix: single-select field with 'contains' filter on mobile does not support multiple selection (#6629)

This commit is contained in:
Katherine 2025-04-07 16:02:51 +08:00 committed by GitHub
parent aa59e0131f
commit d5f99d97df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 12 deletions

View File

@ -129,12 +129,12 @@ export const enumType = [
label: '{{t("is")}}',
value: '$eq',
selected: true,
schema: { 'x-component': 'Select' },
schema: { 'x-component': 'Select', 'x-component-props': { mode: null } },
},
{
label: '{{t("is not")}}',
value: '$ne',
schema: { 'x-component': 'Select' },
schema: { 'x-component': 'Select', 'x-component-props': { mode: null } },
},
{
label: '{{t("is any of")}}',

View File

@ -96,7 +96,7 @@ export const FilterCollectionFieldInternalField: React.FC = (props: Props) => {
const originalProps =
compile({ ...(operator?.schema?.['x-component-props'] || {}), ...(uiSchema['x-component-props'] || {}) }) || {};
field.componentProps = merge(originalProps, field.componentProps || {}, dynamicProps || {});
field.componentProps = merge(field.componentProps || {}, originalProps, dynamicProps || {});
}, [uiSchemaOrigin]);
if (!uiSchemaOrigin) return null;

View File

@ -65,7 +65,6 @@ export const DynamicComponent = (props: Props) => {
...props.style,
},
utc: false,
underFilter: true,
}),
name: 'value',
'x-read-pretty': false,

View File

@ -470,7 +470,6 @@ export const useFilterFormItemInitializerFields = (options?: any) => {
'x-collection-field': `${name}.${field.name}`,
'x-component-props': {
utc: false,
underFilter: true,
},
};
if (isAssocField(field)) {
@ -485,7 +484,7 @@ export const useFilterFormItemInitializerFields = (options?: any) => {
'x-decorator': 'FormItem',
'x-use-decorator-props': 'useFormItemProps',
'x-collection-field': `${name}.${field.name}`,
'x-component-props': { ...field.uiSchema?.['x-component-props'], utc: false, underFilter: true },
'x-component-props': { ...field.uiSchema?.['x-component-props'], utc: false },
};
}
const resultItem = {
@ -580,7 +579,7 @@ const associationFieldToMenu = (
interface: field.interface,
},
'x-component': 'CollectionField',
'x-component-props': { utc: false, underFilter: true },
'x-component-props': { utc: false },
'x-read-pretty': false,
'x-decorator': 'FormItem',
'x-collection-field': `${collectionName}.${schemaName}`,
@ -697,7 +696,7 @@ export const useFilterInheritsFormItemInitializerFields = (options?) => {
'x-component': 'CollectionField',
'x-decorator': 'FormItem',
'x-collection-field': `${name}.${field.name}`,
'x-component-props': { utc: false, underFilter: true },
'x-component-props': { utc: false },
'x-read-pretty': field?.uiSchema?.['x-read-pretty'],
};
return {

View File

@ -16,6 +16,7 @@ import { useTranslation } from 'react-i18next';
const MobilePicker = connect(
(props) => {
const { value, onChange, disabled, options = [], mode } = props;
console.log(props);
const { t } = useTranslation();
const [visible, setVisible] = useState(false);
const [selected, setSelected] = useState(value || []);
@ -42,7 +43,7 @@ const MobilePicker = connect(
disabled={disabled}
value={value}
dropdownStyle={{ display: 'none' }}
multiple={mode === 'multiple'}
multiple={['multiple', 'tags'].includes(mode)}
onClear={() => {
setVisible(false);
onChange(null);
@ -77,10 +78,10 @@ const MobilePicker = connect(
}}
>
<CheckList
multiple={mode === 'multiple'}
multiple={['multiple', 'tags'].includes(mode)}
value={Array.isArray(selected) ? selected : [selected] || []}
onChange={(val) => {
if (mode === 'multiple') {
if (['multiple', 'tags'].includes(mode)) {
setSelected(val);
} else {
setSelected(val[0]);
@ -96,7 +97,7 @@ const MobilePicker = connect(
))}
</CheckList>
</div>
{mode === 'multiple' && (
{['multiple', 'tags'].includes(mode) && (
<Button block color="primary" onClick={handleConfirm} style={{ marginTop: '16px' }}>
{t('Confirm')}
</Button>