fix(popup): fix the issue where popups cannot be opened in embedded pages

This commit is contained in:
Zeke Zhang 2024-11-11 21:30:09 +08:00
parent fe6d12bc68
commit fe101ebf67
2 changed files with 9 additions and 4 deletions

View File

@ -379,7 +379,7 @@ Action.Page = ActionPage;
export default Action; export default Action;
// TODO: Plugin-related code should not exist in the core. It would be better to implement it by modifying the schema, but it would cause incompatibility. // TODO: Plugin-related code should not exist in the core. It would be better to implement it by modifying the schema, but it would cause incompatibility.
function isBulkEditAction(fieldSchema) { export function isBulkEditAction(fieldSchema) {
return fieldSchema['x-action'] === 'customize:bulkEdit'; return fieldSchema['x-action'] === 'customize:bulkEdit';
} }

View File

@ -24,7 +24,7 @@ import _, { omit } from 'lodash';
import React, { useCallback, useContext, useMemo, useRef, useState } from 'react'; import React, { useCallback, useContext, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useInView } from 'react-intersection-observer'; import { useInView } from 'react-intersection-observer';
import { DndContext, useDesignable, useTableSize } from '../..'; import { DndContext, isBulkEditAction, useDesignable, usePopupSettings, useTableSize } from '../..';
import { import {
CollectionRecordProvider, CollectionRecordProvider,
RecordIndexProvider, RecordIndexProvider,
@ -103,6 +103,7 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat
}, []); }, []);
const { current, pageSize } = paginationProps; const { current, pageSize } = paginationProps;
const hasChangedColumns = useColumnsDeepMemoized(columnsSchemas); const hasChangedColumns = useColumnsDeepMemoized(columnsSchemas);
const { isPopupVisibleControlledByURL } = usePopupSettings();
const schemaToolbarBigger = useMemo(() => { const schemaToolbarBigger = useMemo(() => {
return css` return css`
@ -164,7 +165,11 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat
schema={columnSchema} schema={columnSchema}
uiSchema={uiSchema} uiSchema={uiSchema}
onlyRenderProperties onlyRenderProperties
filterProperties={(schema) => schema['x-component'] !== 'Action.Container'} filterProperties={(schema) =>
isBulkEditAction(schema) ||
!isPopupVisibleControlledByURL() ||
schema['x-component'] !== 'Action.Container'
}
/> />
</span> </span>
); );
@ -188,7 +193,7 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat
// 这里不能把 columnsSchema 作为依赖,因为其每次都会变化,这里使用 hasChangedColumns 作为依赖 // 这里不能把 columnsSchema 作为依赖,因为其每次都会变化,这里使用 hasChangedColumns 作为依赖
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
[hasChangedColumns, field.address, collection, schemaToolbarBigger, designable], [hasChangedColumns, field.address, collection, schemaToolbarBigger, designable, isPopupVisibleControlledByURL],
); );
const tableColumns = useMemo(() => { const tableColumns = useMemo(() => {