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

Fixed edges of disabled `IndexTable.Row` `Checkbox` triggering selection
18 changes: 16 additions & 2 deletions polaris-react/src/components/IndexTable/components/Row/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ export const Row = memo(function Row({
event.stopPropagation();
let selectionType = SelectionType.Single;

if (('key' in event && event.key !== ' ') || !onSelectionChange) return;
if (
disabled ||
!selectable ||
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be safe, as handleInteraction is really handling selection, but just want to call out that we should verify that this doesn't prevent onNavigation from being called when a table is not selectable. We had a regression recently and I want to make sure we test that going forward when updating conditionals to require selectability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The onNavigation callback is executed in a different logic branch than the handleInteraction callback, so these two should be unrelated (and unrelated to the above regression).

The logic which follows the new !selectable check is purely for triggering selections, so I'm confident it will behave as expected.

('key' in event && event.key !== ' ') ||
!onSelectionChange
)
return;

if (event.nativeEvent.shiftKey) {
selectionType = SelectionType.Multi;
Expand All @@ -82,7 +88,15 @@ export const Row = memo(function Row({
const selection: string | Range = selectionRange ?? id;
onSelectionChange(selectionType, !selected, selection, position);
},
[id, onSelectionChange, selected, selectionRange, position],
[
id,
onSelectionChange,
selected,
selectionRange,
position,
disabled,
selectable,
],
);

const contextValue = useMemo(
Expand Down