Skip to content

Commit 256e580

Browse files
authored
[ResourceList] Add data-href to ResourceList.Item wrapper (#1054)
1 parent 513c8ea commit 256e580

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

UNRELEASED.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
1616
- Added `download` prop to `Button` and `UnstyledLink` components that enables setting the download attribute ([#1027](https://github.com/Shopify/polaris-react/pull/1027))
1717
- Added support for internationalization of month and week names to `DatePicker` ([#1005](https://github.com/Shopify/polaris-react/pull/1005))
1818
- Added `untrusted` prop to `Icon` to render SVG strings in an img tag ([#926](https://github.com/Shopify/polaris-react/pull/926))
19+
- Added a `data-href` to `ResourceList.Item`s that have a `url` prop ([#1054](https://github.com/Shopify/polaris-react/pull/1054))
1920

2021
### Bug fixes
2122

src/components/ResourceList/components/Item/Item.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ export class Item extends React.PureComponent<CombinedProps, State> {
254254
onMouseDown={this.handleMouseDown}
255255
onKeyUp={this.handleKeypress}
256256
testID="Item-Wrapper"
257+
data-href={url}
257258
>
258259
{accessibleMarkup}
259260
{containerMarkup}

src/components/ResourceList/components/Item/tests/Item.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Item from '../Item';
1313

1414
describe('<Item />', () => {
1515
let spy: jest.SpyInstance;
16+
1617
beforeEach(() => {
1718
spy = jest.spyOn(window, 'open');
1819
});
@@ -122,6 +123,16 @@ describe('<Item />', () => {
122123

123124
expect(element.find(UnstyledLink).prop('aria-label')).toBe(ariaLabel);
124125
});
126+
127+
it('adds a data-href to the wrapper element', () => {
128+
const element = mountWithAppProvider(
129+
<Provider value={mockDefaultContext}>
130+
<Item id="itemId" url={url} />
131+
</Provider>,
132+
);
133+
134+
expect(findByTestID(element, 'Item-Wrapper').prop('data-href')).toBe(url);
135+
});
125136
});
126137

127138
describe('id', () => {

0 commit comments

Comments
 (0)