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; return child;
}); });
}; };
const isDisabled = !hasAccess(role) && !fineGrainedAccess;
return ( return (
<> <>
{!unWrap && ( {!unWrap && (
<Form {...rest}> <Form {...rest}>
{recursiveCloneChildren(children, { {recursiveCloneChildren(children, isDisabled ? { isDisabled } : {})}
isDisabled: !hasAccess(role) && !fineGrainedAccess,
})}
</Form> </Form>
)} )}
{unWrap && {unWrap &&
recursiveCloneChildren(children, { recursiveCloneChildren(children, isDisabled ? { isDisabled } : {})}
isDisabled: !hasAccess(role) && !fineGrainedAccess,
})}
</> </>
); );
}; };

View file

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