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/seven-suns-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
---

Removed extra padding around `IndexTable.Row` `Checkbox`
10 changes: 8 additions & 2 deletions polaris-react/src/components/IndexTable/IndexTable.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
--pc-index-table-sticky-cell: 29;
--pc-index-table-bulk-actions: 31;
--pc-index-table-loading-panel: 31;
--pc-index-table-checkbox-offset-left: var(--p-space-300);
--pc-index-table-checkbox-offset-right: var(--p-space-200);
/* stylelint-enable */
position: relative;
border-radius: 0;
Expand Down Expand Up @@ -804,8 +806,6 @@
/* stylelint-disable -- Polaris component custom properties */
--pc-index-table-heading-padding-x: var(--p-space-150);
--pc-index-table-heading-padding-y: var(--p-space-200);
--pc-index-table-checkbox-offset-left: var(--p-space-300);
--pc-index-table-checkbox-offset-right: var(--p-space-200);
background: var(--p-color-bg-surface-secondary);
padding: var(--pc-index-table-heading-padding-y)
var(--pc-index-table-heading-padding-x);
Expand Down Expand Up @@ -1027,6 +1027,12 @@

&:first-child {
padding-left: var(--p-space-300);

/* stylelint-disable-next-line selector-max-specificity -- This is a valid selector */
.Table:not(.Table-unselectable) & {
/* stylelint-disable-next-line -- specificity overrides */
padding-right: var(--pc-index-table-checkbox-offset-right);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is --p-space-200 (ie; 8px). Before it was getting --p-space-150 (6px) from above.

The 2px difference was being added to the inner width of the element, making it 20px wide even though the checkbox is only 18px wide.

Later, when the checkbox is rendered, it was then being wrapped in a flex container whos only job was to re-center the checkbox due to the added 2px.

So, by setting the correct padding here, we can remove the unnecessary div later 👍

}
}

&:last-child {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.TableCellContentContainer {
display: flex;
align-items: center;
}

.Wrapper {
display: flex;
justify-content: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ export const Checkbox = memo(function Checkbox({

return (
<CheckboxWrapper>
<div className={styles.TableCellContentContainer}>
<div className={styles.Wrapper} onClick={onInteraction} onKeyUp={noop}>
<PolarisCheckbox
id={`Select-${itemId}`}
label={label}
labelHidden
checked={selected}
disabled={disabled}
/>
</div>
<div className={styles.Wrapper} onClick={onInteraction} onKeyUp={noop}>
<PolarisCheckbox
id={`Select-${itemId}`}
label={label}
labelHidden
checked={selected}
disabled={disabled}
/>
</div>
</CheckboxWrapper>
);
Expand Down