+
+ );
+};
diff --git a/packages/module/patternfly-docs/content/extensions/data-view/examples/Table/Table.md b/packages/module/patternfly-docs/content/extensions/data-view/examples/Table/Table.md
index 60b60034..e394a90c 100644
--- a/packages/module/patternfly-docs/content/extensions/data-view/examples/Table/Table.md
+++ b/packages/module/patternfly-docs/content/extensions/data-view/examples/Table/Table.md
@@ -114,6 +114,7 @@ When sticky headers and columns are enabled:
- Columns marked with `isStickyColumn: true` remain visible when scrolling horizontally
- The table is wrapped in `OuterScrollContainer` and `InnerScrollContainer` components to enable sticky behavior
- Sticky columns can have additional styling like borders using `hasRightBorder` or `hasLeftBorder` props
+- When selection is enabled (via ``), the selection checkbox column automatically becomes sticky when the first data column has `isStickyColumn: true`. The selection column is properly offset to appear to the left of the sticky data column.
### Sticky header and columns example
@@ -121,6 +122,14 @@ When sticky headers and columns are enabled:
```
+### Sticky selection column example
+
+This example demonstrates how the selection checkbox column automatically becomes sticky when the first data column has `isStickyColumn: true`. The selection column is positioned at the left edge with proper offset handling.
+
+```js file="./DataViewTableStickySelectionExample.tsx"
+
+```
+
### Interactive example
- This interactive example shows how the different composable options work together
- By toggling the toggles, you can switch between them and observe the behaviour
diff --git a/packages/module/patternfly-docs/generated/index.js b/packages/module/patternfly-docs/generated/index.js
index be229904..4041f4dc 100644
--- a/packages/module/patternfly-docs/generated/index.js
+++ b/packages/module/patternfly-docs/generated/index.js
@@ -14,8 +14,8 @@ module.exports = {
'/extensions/data-view/table/react': {
id: "Table",
title: "Data view table",
- toc: [{"text":"Configuring rows and columns"},[{"text":"Table example"}],{"text":"Adding expandable content to rows"},{"text":"Expandable rows"},[{"text":"Expandable rows example"}],{"text":"Compound expandable rows"},[{"text":"Compound expandable rows example"}],{"text":"Sticky header and columns"},[{"text":"Sticky header and columns example"},{"text":"Interactive example"},{"text":"Resizable columns"}],{"text":"Tree table"},[{"text":"Tree table example"}],{"text":"Sorting"},[{"text":"Sorting example"},{"text":"Sorting state"}],{"text":"States"},[{"text":"Empty"},{"text":"Error"},{"text":"Loading"}]],
- examples: ["Table example","Expandable rows example","Compound expandable rows example","Sticky header and columns example","Interactive example","Resizable columns","Tree table example","Sorting example","Empty","Error","Loading"],
+ toc: [{"text":"Configuring rows and columns"},[{"text":"Table example"}],{"text":"Adding expandable content to rows"},{"text":"Expandable rows"},[{"text":"Expandable rows example"}],{"text":"Compound expandable rows"},[{"text":"Compound expandable rows example"}],{"text":"Sticky header and columns"},[{"text":"Sticky header and columns example"},{"text":"Sticky selection column example"},{"text":"Interactive example"},{"text":"Resizable columns"}],{"text":"Tree table"},[{"text":"Tree table example"}],{"text":"Sorting"},[{"text":"Sorting example"},{"text":"Sorting state"}],{"text":"States"},[{"text":"Empty"},{"text":"Error"},{"text":"Loading"}]],
+ examples: ["Table example","Expandable rows example","Compound expandable rows example","Sticky header and columns example","Sticky selection column example","Interactive example","Resizable columns","Tree table example","Sorting example","Empty","Error","Loading"],
section: "extensions",
subsection: "Data view",
source: "react",
@@ -35,4 +35,4 @@ module.exports = {
sortValue: 1,
Component: () => import(/* webpackChunkName: "extensions/data-view/overview/extensions/index" */ './extensions/data-view/overview/extensions')
}
-};
\ No newline at end of file
+};
diff --git a/packages/module/src/DataViewTableBasic/DataViewTableBasic.tsx b/packages/module/src/DataViewTableBasic/DataViewTableBasic.tsx
index 1bae556f..032f633f 100644
--- a/packages/module/src/DataViewTableBasic/DataViewTableBasic.tsx
+++ b/packages/module/src/DataViewTableBasic/DataViewTableBasic.tsx
@@ -93,11 +93,18 @@ export const DataViewTableBasic: FC = ({
// Find all expandable contents for this row
const rowExpandableContents = isExpandable ? expandedRows?.filter(matchesRow) : [];
+ // Check if the first cell in this row has isStickyColumn
+ const firstCellProps = rowData[0] && isDataViewTdObject(rowData[0]) ? (rowData[0]?.props ?? {}) : {};
+ const firstCellIsSticky = firstCellProps.isStickyColumn;
+
const rowContent = (
{isSelectable && (
{
@@ -125,10 +132,18 @@ export const DataViewTableBasic: FC = ({
const cellExpandableContent = isCompoundExpandable
? expandedRows?.find((entry) => matchesRow(entry) && entry.columnId === colIndex)
: undefined;
+
+ // Get the cell props
+ const cellProps = cellIsObject ? (cell?.props ?? {}) : {};
+ // If the first column is sticky and selection is enabled, offset it by the selection column width
+ const enhancedCellProps = colIndex === 0 && cellProps.isStickyColumn && isSelectable
+ ? { ...cellProps, stickyLeftOffset: '45px' }
+ : cellProps;
+
return (