From f56f49d3ca2eb3c806340a0ba9355107736bd43c Mon Sep 17 00:00:00 2001 From: Sheldon Guo Date: Wed, 27 Nov 2024 13:27:35 +0800 Subject: [PATCH] fix(RemoteSelect component): fix selected option label not loaded on first render (#5736) * feat: add defaultParams option to service in RemoteSelect and UsersSelect components * fix: conditionally set defaultParams in RemoteSelect component --- .../src/schema-component/antd/remote-select/RemoteSelect.tsx | 5 ++++- .../src/client/components/UsersSelect.tsx | 2 +- .../client/manager/receiver/components/User/UserSelect.tsx | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/remote-select/RemoteSelect.tsx b/packages/core/client/src/schema-component/antd/remote-select/RemoteSelect.tsx index 9fb83fb75b..fa47bb9559 100644 --- a/packages/core/client/src/schema-component/antd/remote-select/RemoteSelect.tsx +++ b/packages/core/client/src/schema-component/antd/remote-select/RemoteSelect.tsx @@ -39,7 +39,9 @@ export type RemoteSelectProps

= SelectProps & { /** * useRequest() `service` parameter */ - service: ResourceActionOptions

; + service: ResourceActionOptions

& { + defaultParams?: any; + }; target: string; mapOptions?: (data: any) => SelectProps['fieldNames']; dataSource?: string; @@ -177,6 +179,7 @@ const InternalRemoteSelect = withDynamicSchemaProps( { manual, debounceWait: wait, + ...(service.defaultParams ? { defaultParams: [service.defaultParams] } : {}), }, ); const runDep = useMemo( diff --git a/packages/plugins/@nocobase/plugin-notification-in-app-message/src/client/components/UsersSelect.tsx b/packages/plugins/@nocobase/plugin-notification-in-app-message/src/client/components/UsersSelect.tsx index 17efd362e4..debfad5c7a 100644 --- a/packages/plugins/@nocobase/plugin-notification-in-app-message/src/client/components/UsersSelect.tsx +++ b/packages/plugins/@nocobase/plugin-notification-in-app-message/src/client/components/UsersSelect.tsx @@ -36,7 +36,6 @@ export function UsersSelect(props) { function InternalUsersSelect({ value, onChange }) { const scope = useWorkflowVariableOptions({ types: [isUserKeyField] }); - return (