Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/light-seahorses-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this bug existed prior to se23, I've added a changeset to track the fix.

---

Fixed broken focus ring styles on `ResourceItem` component
77 changes: 50 additions & 27 deletions polaris-react/src/components/ResourceItem/ResourceItem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
}

.ListItem {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
// stylelint-disable-next-line -- include focus-ring mixin to prevent jump in content for first focused element
@include focus-ring($border-width: -1px);

.ListItem + & {
Expand All @@ -120,38 +120,61 @@
@include item-separator;
}

&:not(.hasBulkActions):not(.selectMode) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored this logic since we're no longer relying on ::after and moved hasBulkActions focus ring styles to inside .focused class.

// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
&::after {
border-radius: var(--p-border-radius-05);
}
&.focused {
// stylelint-disable-next-line -- remove focus-ring mixin to use outline styles
@include no-focus-ring;
outline: var(--p-border-width-2) solid
var(--p-color-border-interactive-focus);
outline-offset: calc(-1 * var(--p-space-05));
// stylelint-disable-next-line -- custom property
z-index: var(--pc-resource-item-clickable-stacking-order);
border-radius: var(--p-border-radius-0-experimental);

// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
&:last-of-type {
border-bottom-left-radius: var(--p-border-radius-2);
border-bottom-right-radius: var(--p-border-radius-2);
// stylelint-disable selector-max-specificity -- Needed due to the nesting of the elements that change border-radius based on selection mode
.ItemWrapper {
border-radius: inherit;
@media #{$p-breakpoints-sm-up} {
border-radius: var(--p-border-radius-3);

&:first-of-type {
border-bottom-left-radius: var(--p-border-radius-0-experimental);
border-bottom-right-radius: var(--p-border-radius-0-experimental);
}

&.focused::after {
border-bottom-left-radius: var(--p-border-radius-2);
border-bottom-right-radius: var(--p-border-radius-2);
&:last-of-type {
border-top-left-radius: var(--p-border-radius-0-experimental);
border-top-right-radius: var(--p-border-radius-0-experimental);
}
// stylelint-enable
}
}

&.focused {
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
@include focus-ring($style: 'focused');
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
z-index: var(--pc-resource-item-clickable-stacking-order);
}
&:only-child {
border-radius: var(--p-border-radius-0-experimental);

// stylelint-disable-next-line selector-max-specificity, selector-max-combinators -- generated by polaris-migrator DO NOT COPY
* + ul > &:first-of-type.focused::after {
top: 1px;
@media #{$p-breakpoints-sm-up} {
border-radius: var(--p-border-radius-3);
}
}

// stylelint-disable-next-line selector-max-class -- set border radius for selectable items
&.selectable {
border-radius: var(--p-border-radius-0-experimental);

@media #{$p-breakpoints-sm-up} {
// stylelint-disable-next-line -- set border radius for last selectable item to match ResourceList border radius
&:last-child {
border-bottom-left-radius: var(--p-border-radius-3);
border-bottom-right-radius: var(--p-border-radius-3);
}

// stylelint-disable-next-line -- set border radius for last selectable item to match BulkActions border radius
&.hasBulkActions {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified refactoring this displays proper focus on selectable ResourceItems but resets border bottom radius to 0 specifically to match styling when BulkActions are rendered:

bulkactions

// stylelint-disable-next-line -- set border radius for last selectable item to match BulkActions border radius
&:last-child {
// stylelint-disable-next-line -- set border radius for last selectable item to match BulkActions border radius
&.selected {
border-bottom-left-radius: var(--p-border-radius-0-experimental);
border-bottom-right-radius: var(--p-border-radius-0-experimental);
}
}
}
}
}
}
}
16 changes: 16 additions & 0 deletions polaris-react/src/components/ResourceItem/ResourceItem.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ export function SelectableWithMedia() {
name: 'Yi So-Yeon',
location: 'Gwangju, South Korea',
},
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more items to test focus ring border styles for first/second/last children for ResourceItem.

id: '146',
url: '#',
avatarSource:
'https://burst.shopifycdn.com/photos/woman-standing-in-front-of-yellow-background.jpg?width=746',
name: 'Jane Smith',
location: 'Manhattan, New York',
},
{
id: '147',
url: '#',
avatarSource:
'https://burst.shopifycdn.com/photos/relaxing-in-headphones.jpg?width=746',
name: 'Grace Baker',
location: 'Los Angeles, California',
},
]}
renderItem={(item) => {
const {id, url, avatarSource, name, location} = item;
Expand Down
2 changes: 2 additions & 0 deletions polaris-react/src/components/ResourceItem/ResourceItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class BaseResourceItem extends Component<CombinedProps, State> {
styles.ListItem,
focused && !focusedInner && styles.focused,
hasBulkActions && styles.hasBulkActions,
selected && styles.selected,
selectable && styles.selectable,
);

let actionsMarkup: React.ReactNode | null = null;
Expand Down
32 changes: 16 additions & 16 deletions polaris-react/src/components/ResourceList/ResourceList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {

export function Default() {
return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added roundedAbove="sm" prop to ResourceList stories to match styling on IndexTable.

<ResourceList
resourceName={{singular: 'customer', plural: 'customers'}}
items={[
Expand Down Expand Up @@ -94,7 +94,7 @@ export function WithEmptyState() {
<Page title="Files">
<Layout>
<Layout.Section>
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
emptyState={emptyStateMarkup}
items={items}
Expand Down Expand Up @@ -133,7 +133,7 @@ export function WithSelectionAndNoBulkActions() {
];

return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={resourceName}
items={items}
Expand Down Expand Up @@ -213,7 +213,7 @@ export function WithBulkActions() {
];

return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={resourceName}
items={items}
Expand Down Expand Up @@ -290,7 +290,7 @@ export function WithBulkActionsAndManyItems() {
];

return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={resourceName}
items={items}
Expand Down Expand Up @@ -371,7 +371,7 @@ export function WithLoadingState() {
];

return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={resourceName}
items={items}
Expand Down Expand Up @@ -409,7 +409,7 @@ export function WithLoadingState() {

export function WithTotalCount() {
return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={{singular: 'customer', plural: 'customers'}}
items={[
Expand Down Expand Up @@ -455,7 +455,7 @@ export function WithTotalCount() {

export function WithHeaderContent() {
return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
headerContent="Customer details shown below"
items={[
Expand Down Expand Up @@ -522,7 +522,7 @@ export function WithSorting() {
];

return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={resourceName}
items={items}
Expand Down Expand Up @@ -584,7 +584,7 @@ export function WithAlternateTool() {
];

return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
items={items}
renderItem={renderItem}
Expand Down Expand Up @@ -694,7 +694,7 @@ export function WithFiltering() {
);

return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={resourceName}
items={items}
Expand Down Expand Up @@ -806,7 +806,7 @@ export function WithACustomEmptySearchResultState() {
);

return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={resourceName}
items={items}
Expand Down Expand Up @@ -853,7 +853,7 @@ export function WithACustomEmptySearchResultState() {

export function WithItemShortcutActions() {
return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={{singular: 'customer', plural: 'customers'}}
items={[
Expand Down Expand Up @@ -909,7 +909,7 @@ export function WithItemShortcutActions() {

export function WithPersistentItemShortcutActions() {
return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={{singular: 'customer', plural: 'customers'}}
items={[
Expand Down Expand Up @@ -1034,7 +1034,7 @@ export function WithMultiselect() {
];

return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={resourceName}
items={items}
Expand Down Expand Up @@ -1183,7 +1183,7 @@ export function WithAllOfItsElements() {
);

return (
<Card padding="0">
<Card padding="0" roundedAbove="sm">
<ResourceList
resourceName={resourceName}
items={items}
Expand Down