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")}}', label: '{{t("is")}}',
value: '$eq', value: '$eq',
selected: true, selected: true,
schema: { 'x-component': 'Select' }, schema: { 'x-component': 'Select', 'x-component-props': { mode: null } },
}, },
{ {
label: '{{t("is not")}}', label: '{{t("is not")}}',
value: '$ne', value: '$ne',
schema: { 'x-component': 'Select' }, schema: { 'x-component': 'Select', 'x-component-props': { mode: null } },
}, },
{ {
label: '{{t("is any of")}}', label: '{{t("is any of")}}',

View File

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

View File

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

View File

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

View File

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