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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(react-table): Adding stop propagation to focusable elements in DataGrid so that clicking on them does not toggle cell selection #33262

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ const items: Item[] = [
},
];

const onButtonClick = (ev: React.MouseEvent<HTMLButtonElement>) => {
ev.stopPropagation();
};

const columns: TableColumnDefinition<Item>[] = [
createTableColumn<Item>({
columnId: 'file',
Expand Down Expand Up @@ -108,7 +112,11 @@ const columns: TableColumnDefinition<Item>[] = [
return 'Single action';
},
renderCell: () => {
return <Button icon={<OpenRegular />}>Open</Button>;
return (
<Button icon={<OpenRegular />} onClick={onButtonClick}>
Open
</Button>
);
},
}),
createTableColumn<Item>({
Expand All @@ -119,8 +127,8 @@ const columns: TableColumnDefinition<Item>[] = [
renderCell: () => {
return (
<>
<Button aria-label="Edit" icon={<EditRegular />} />
<Button aria-label="Delete" icon={<DeleteRegular />} />
<Button aria-label="Edit" icon={<EditRegular />} onClick={onButtonClick} />
<Button aria-label="Delete" icon={<DeleteRegular />} onClick={onButtonClick} />
</>
);
},
Expand Down Expand Up @@ -181,6 +189,8 @@ FocusableElementsInCells.parameters = {
'',
'Use `none` when there is one single focusable element in cell,',
'`none` will make the cell non-focusable',
'',
'Stop propagation of events on focusable elements to prevent cell selection from changing.',
].join('\n'),
},
},
Expand Down
Loading