From be2268df2fc0caf23e7b44cbc7c1efd696c0b035 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 12 Jan 2021 01:43:32 +0100 Subject: [PATCH] only add isDisabled when needed otherwise (#289) as before it would override an existing isDisabled --- src/components/form-access/FormAccess.tsx | 11 +++++------ .../__tests__/__snapshots__/FormAccess.test.tsx.snap | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/form-access/FormAccess.tsx b/src/components/form-access/FormAccess.tsx index 3d8eaf453f..6d6c3bebaa 100644 --- a/src/components/form-access/FormAccess.tsx +++ b/src/components/form-access/FormAccess.tsx @@ -99,19 +99,18 @@ export const FormAccess = ({ return child; }); }; + + const isDisabled = !hasAccess(role) && !fineGrainedAccess; + return ( <> {!unWrap && (
- {recursiveCloneChildren(children, { - isDisabled: !hasAccess(role) && !fineGrainedAccess, - })} + {recursiveCloneChildren(children, isDisabled ? { isDisabled } : {})}
)} {unWrap && - recursiveCloneChildren(children, { - isDisabled: !hasAccess(role) && !fineGrainedAccess, - })} + recursiveCloneChildren(children, isDisabled ? { isDisabled } : {})} ); }; diff --git a/src/components/form-access/__tests__/__snapshots__/FormAccess.test.tsx.snap b/src/components/form-access/__tests__/__snapshots__/FormAccess.test.tsx.snap index a0716f0061..55821eba20 100644 --- a/src/components/form-access/__tests__/__snapshots__/FormAccess.test.tsx.snap +++ b/src/components/form-access/__tests__/__snapshots__/FormAccess.test.tsx.snap @@ -41,7 +41,6 @@ exports[` render normal form 1`] = ` >