Skip to content

Commit

Permalink
Merge pull request #206 from creative-commoners/pulls/4/disabled-delete
Browse files Browse the repository at this point in the history
FIX Do not show delete button when disabled
  • Loading branch information
GuySartorelli authored Feb 7, 2024
2 parents 4e9713c + 31d9ffa commit 533f9ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/src/components/LinkPicker/LinkPickerTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const LinkPickerTitle = ({
<span className="link-picker__url">{description}</span>
</small>
</div>
{(canDelete && !readonly) &&
{(canDelete && !readonly && !disabled) &&
// This is a <span> rather than a <Button> because we're inside a <Button> and
// trigger an error when you attempt to nest a <Button> inside a <Button>.
<span
Expand Down
14 changes: 14 additions & 0 deletions client/src/components/LinkPicker/tests/LinkPickerTitle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ test('LinkPickerTitle render() should not display clear button if cannot delete'
expect(container.querySelectorAll('.link-picker__delete')).toHaveLength(0);
});

test('LinkPickerTitle render() should not display clear button if readonly', () => {
const { container } = render(<LinkFieldContext.Provider value={{ loading: false }}>
<LinkPickerTitle {...makeProps({ readonly: true })} />
</LinkFieldContext.Provider>);
expect(container.querySelectorAll('.link-picker__delete')).toHaveLength(0);
});

test('LinkPickerTitle render() should not display clear button if disabled', () => {
const { container } = render(<LinkFieldContext.Provider value={{ loading: false }}>
<LinkPickerTitle {...makeProps({ readonly: true })} />
</LinkFieldContext.Provider>);
expect(container.querySelectorAll('.link-picker__delete')).toHaveLength(0);
});

test('LinkPickerTitle render() should display link type icon', () => {
const { container } = render(<LinkFieldContext.Provider value={{ loading: false }}>
<LinkPickerTitle {...makeProps({ canDelete: false })} />
Expand Down

0 comments on commit 533f9ed

Please sign in to comment.