mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 11:46:46 +00:00
fix: allow collection provider to be null
This commit is contained in:
parent
5dae47d5f1
commit
01134f8253
@ -3,11 +3,11 @@ import { CollectionContext } from './context';
|
||||
import { useCollectionManager } from './hooks';
|
||||
import { CollectionOptions } from './types';
|
||||
|
||||
export const CollectionProvider: React.FC<{ name?: string; collection?: CollectionOptions }> = (props) => {
|
||||
const { name, collection, children } = props;
|
||||
export const CollectionProvider: React.FC<{ allowNull?: boolean; name?: string; collection?: CollectionOptions }> = (props) => {
|
||||
const { allowNull, name, collection, children } = props;
|
||||
const { getCollection } = useCollectionManager();
|
||||
const value = getCollection(collection || name);
|
||||
if (!value) {
|
||||
if (!value && !allowNull) {
|
||||
return null;
|
||||
}
|
||||
return <CollectionContext.Provider value={value}>{children}</CollectionContext.Provider>;
|
||||
|
@ -97,7 +97,7 @@ export const InputRecordPicker: React.FC<any> = (props) => {
|
||||
open={false}
|
||||
/>
|
||||
<RecordPickerContext.Provider value={{ multiple, onChange, selectedRows, setSelectedRows }}>
|
||||
<CollectionProvider name={collectionField?.target}>
|
||||
<CollectionProvider allowNull name={collectionField?.target}>
|
||||
<ActionContext.Provider value={{ openMode: 'drawer', visible, setVisible }}>
|
||||
<FormProvider>
|
||||
<SchemaComponentOptions scope={{ useTableSelectorProps, usePickActionProps }}>
|
||||
|
Loading…
Reference in New Issue
Block a user