fix: templateBlockProvider support association field append

This commit is contained in:
katherinehhh 2024-03-29 10:32:47 +08:00 committed by sealday
parent 98e18a1a3a
commit 9acb908981
2 changed files with 9 additions and 4 deletions

View File

@ -30,6 +30,7 @@ import { DataBlockCollector } from '../filter-provider/FilterProvider';
import { RecordProvider, useRecordIndex } from '../record-provider';
import { useAssociationNames } from './hooks';
import { useDataBlockSourceId } from './hooks/useDataBlockSourceId';
import { useTemplateBlockContext } from './TemplateBlockProvider';
/**
* @deprecated
@ -228,6 +229,7 @@ export const BlockProvider = (props: {
}) => {
const { name, dataSource, association, useParams, parentRecord } = props;
const sourceId = useCompatDataBlockSourceId(props);
const { templateFinshed } = useTemplateBlockContext();
// 新版1.0)已弃用 useParams这里之所以继续保留是为了兼容旧版的 UISchema
const paramsFromHook = useParams?.();
@ -239,7 +241,7 @@ export const BlockProvider = (props: {
return { ...props.params, appends, ...paramsFromHook };
}
return { ...props.params, ...paramsFromHook };
}, [appends, paramsFromHook, props.params]);
}, [appends, paramsFromHook, props.params, templateFinshed]);
const blockValue = useMemo(() => ({ name }), [name]);
return (

View File

@ -8,6 +8,7 @@ import { RecordProvider } from '../record-provider';
import { BlockProvider, useBlockRequestContext } from './BlockProvider';
import { useParsedFilter } from './hooks';
import { withDynamicSchemaProps } from '../application/hoc/withDynamicSchemaProps';
import { TemplateBlockProvider } from './TemplateBlockProvider';
export const DetailsBlockContext = createContext<any>({});
DetailsBlockContext.displayName = 'DetailsBlockContext';
@ -64,9 +65,11 @@ const InternalDetailsBlockProvider = (props) => {
export const DetailsBlockProvider = withDynamicSchemaProps((props) => {
return (
<BlockProvider name="details" {...props}>
<InternalDetailsBlockProvider {...props} />
</BlockProvider>
<TemplateBlockProvider>
<BlockProvider name="details" {...props}>
<InternalDetailsBlockProvider {...props} />
</BlockProvider>
</TemplateBlockProvider>
);
});