Skip to content

Commit

Permalink
fix(Datagrid): use selectedRowIds to set selected rows (#3123)
Browse files Browse the repository at this point in the history
* fix(Datagrid): use selectedRowIds to set selected rows

* chore: remove comment
  • Loading branch information
matthewgallo authored Jun 13, 2023
1 parent 32a25a3 commit 426b8b4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ export const SelectItemsInAllPages = () => {
},
DatagridPagination,
DatagridActions,
DatagridBatchActions,
batchActions: true,
toolbarBatchActions: getBatchActions(),
},
useSelectRows,
useSelectAllWithToggle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const SelectAllWithToggle = ({
columns,
withStickyColumn,
}) => {
const { onSelectAllRows, labels } = selectAllToggle || {};
const [selectAllMode, setSelectAllMode] = useState(SELECT_ALL_PAGE_ROWS);
useEffect(() => {
if (onSelectAllRows) {
Expand All @@ -46,7 +47,6 @@ const SelectAllWithToggle = ({
return () => window.removeEventListener('resize', updateSize);
}, []);

const { onSelectAllRows, labels } = selectAllToggle || {};
if (labels) {
allPageRowsLabel = labels.allPageRows || allPageRowsLabel;
allRowsLabel = labels.allRows || allRowsLabel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ const DatagridBatchActionsToolbar = (datagridState, width, ref) => {
const [initialListWidth, setInitialListWidth] = useState(null);
const [receivedInitialWidth, setReceivedInitialWidth] = useState(false);
const {
selectedFlatRows,
state: { selectedRowIds },
toggleAllRowsSelected,
toolbarBatchActions,
setGlobalFilter,
} = datagridState;
const totalSelected = selectedFlatRows && selectedFlatRows.length;
const totalSelected = Object.keys(selectedRowIds || {})?.length;

// Get initial width of batch actions container,
// used to measure when all items are put inside
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $block-class: #{c4p-settings.$pkg-prefix}--datagrid;
height: 100vh;
}

.sb-show-main.sb-main-centered #root {
.sb-show-main.sb-main-centered #storybook-root {
width: 100%;
height: 100vh;
padding: $spacing-07;
Expand Down

0 comments on commit 426b8b4

Please sign in to comment.