Skip to content

Commit

Permalink
refactor: disable add button with disabled: true
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Sep 25, 2023
1 parent 5c54186 commit 2f35e90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ const DepartmentsNameEdit = ({ departments, disabled }) => {
return (
<div className={css.repeatableFieldRemoveItem}>
<FieldArray
addLabel={!disabled && <FormattedMessage id="ui-users.extended.department.add" />}
addLabel={<FormattedMessage id="ui-users.extended.department.add" />}
legend={<FormattedMessage id="ui-users.extended.department.name" />}
id="department-name"
component={RepeatableField}
name="departments"
onAdd={fields => fields.push()}
canRemove={!disabled}
canAdd={!disabled}
renderField={field => (
<Field
component={Select}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ describe('Given DepartmentsNameEdit', () => {
describe('Given DepartmentsNameEdit with disabled: true', () => {
it('should not render add button', async () => {
renderDepartmentsNameEdit({ ...props, disabled: true });
expect(screen.queryByText('ui-users.extended.department.add')).not.toBeInTheDocument();
expect(screen.getByRole('button')).toBeDisabled();
});
});

0 comments on commit 2f35e90

Please sign in to comment.