Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ActionList/Item] Fix disabling ActionList Item when url prop is passed #3979

Merged
merged 3 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
- Fixed click propagation that was preventing the `Tooltip` to open when used as suffix on a `TextField` ([#3956](https://github.com/Shopify/polaris-react/issues/3956))
- Made items in `ActionList` more clear in high contrast mode ([#3971](https://github.com/Shopify/polaris-react/pull/3971))
- Fixed the MediaCard thumbnail鈥檚 corner roundness, so it wouldn鈥檛 overflow out of the parent Card ([#3974](https://github.com/Shopify/polaris-react/issues/3974))
- Fixed `ActionList` `Item` not disabling properly when url prop is passed ([#3979](https://github.com/Shopify/polaris-react/pull/3979))

### Documentation

Expand Down
4 changes: 2 additions & 2 deletions src/components/ActionList/components/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ export function Item({
const control = url ? (
<UnstyledLink
id={id}
url={url}
url={disabled ? null : url}
className={className}
external={external}
aria-label={accessibilityLabel}
onClick={onAction}
onClick={disabled ? null : onAction}
>
{contentElement}
</UnstyledLink>
Expand Down
14 changes: 14 additions & 0 deletions src/components/ActionList/components/Item/tests/Item.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ describe('<Item />', () => {
mockAccessibilityLabel,
);
});

it('passes `url` as null to `<UnstyledLink />` when disabled', () => {
const item = mountWithApp(<Item url="https://shopify.com" disabled />);

expect(item.find(UnstyledLink)!.prop('url')).toBeNull();
});

it('passes `onClick` as null to `<UnstyledLink />` when disabled', () => {
const item = mountWithApp(
<Item onAction={noop} disabled url="https://shopify.com" />,
);

expect(item.find(UnstyledLink)!.prop('onClick')).toBeNull();
});
});

function noop() {}