only add isDisabled when needed otherwise (#289)

as before it would override an existing isDisabled
This commit is contained in:
Erik Jan de Wit 2021-01-12 01:43:32 +01:00 committed by GitHub
parent 853fd2c220
commit be2268df2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View file

@ -99,19 +99,18 @@ export const FormAccess = ({
return child;
});
};
const isDisabled = !hasAccess(role) && !fineGrainedAccess;
return (
<>
{!unWrap && (
<Form {...rest}>
{recursiveCloneChildren(children, {
isDisabled: !hasAccess(role) && !fineGrainedAccess,
})}
{recursiveCloneChildren(children, isDisabled ? { isDisabled } : {})}
</Form>
)}
{unWrap &&
recursiveCloneChildren(children, {
isDisabled: !hasAccess(role) && !fineGrainedAccess,
})}
recursiveCloneChildren(children, isDisabled ? { isDisabled } : {})}
</>
);
};

View file

@ -41,7 +41,6 @@ exports[`<FormAccess /> render normal form 1`] = `
>
<TextInput
id="field"
isDisabled={false}
key=".0"
name="fieldName"
type="text"