Skip to content

Commit 0286010

Browse files
authored
Fix regression on disabled elements for SecureComponent (#1478)
Signed-off-by: Lenin Alevski <[email protected]>
1 parent 382e315 commit 0286010

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

portal-ui/src/common/SecureComponent/SecureComponent.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,15 @@ const SecureComponent = ({
5858
resource,
5959
}: ISecureComponentProps) => {
6060
const permissionGranted = hasPermission(resource, scopes, matchAll);
61-
const childComponent = <>{children}</>;
6261
if (!permissionGranted && !errorProps) return <RenderError />;
6362
if (!permissionGranted && errorProps) {
64-
return cloneElement(childComponent, { ...errorProps });
63+
return Array.isArray(children) ? (
64+
<>{children.map((child) => cloneElement(child, { ...errorProps }))}</>
65+
) : (
66+
cloneElement(children, { ...errorProps })
67+
);
6568
}
66-
return childComponent;
69+
return <>{children}</>;
6770
};
6871

6972
export default SecureComponent;

0 commit comments

Comments
 (0)