Skip to content

Commit

Permalink
Disable header row marker on single selection
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmasuch committed Apr 3, 2024
1 parent 3a97523 commit 12883ca
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/core/src/data-editor/data-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
const rowMarkerTheme = rowMarkersObj?.theme ?? p.rowMarkerTheme;
const headerRowMarkerTheme = rowMarkersObj?.headerTheme;
const headerRowMarkerAlwaysVisible = rowMarkersObj?.headerAlwaysVisible;
const headerRowMarkerDisabled = rowSelect !== "multi";
const rowMarkerCheckboxStyle = rowMarkersObj?.checkboxStyle ?? "square";

const minColumnWidth = Math.max(minColumnWidthIn, 20);
Expand Down Expand Up @@ -1112,6 +1113,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
rowMarkerChecked,
headerRowMarkerTheme,
headerRowMarkerAlwaysVisible,
headerRowMarkerDisabled,
},
...columns,
];
Expand All @@ -1124,6 +1126,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
rowMarkerChecked,
headerRowMarkerTheme,
headerRowMarkerAlwaysVisible,
headerRowMarkerDisabled,
]);

const visibleRegionRef = React.useRef<VisibleRegion>({
Expand Down Expand Up @@ -1795,7 +1798,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
} else {
setSelectedRows(CompactSelection.fromSingleSelection(newSlice), undefined, isMultiRow);
}
} else if (isMultiRow || args.isTouch || rowSelectionMode === "multi") {
} else if (rowSelect === "multi" && (isMultiRow || args.isTouch || rowSelectionMode === "multi")) {
if (isSelected) {
setSelectedRows(selectedRows.remove(row), undefined, true);
} else {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/internal/data-grid/data-grid-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export type InnerColumnExtension = {
rowMarkerChecked?: BooleanIndeterminate | boolean;
headerRowMarkerTheme?: Partial<Theme>;
headerRowMarkerAlwaysVisible?: boolean;
headerRowMarkerDisabled?: boolean;
};

/** @category Columns */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function useMappedColumns(
rowMarkerChecked: c.rowMarkerChecked,
headerRowMarkerTheme: c.headerRowMarkerTheme,
headerRowMarkerAlwaysVisible: c.headerRowMarkerAlwaysVisible,
headerRowMarkerDisabled: c.headerRowMarkerDisabled,
})
),
[columns, freezeColumns]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ function drawHeaderInner(
isRtl: boolean,
headerLayout: HeaderLayout
) {
if (c.rowMarker !== undefined) {
if (c.rowMarker !== undefined && c.headerRowMarkerDisabled !== true) {
const checked = c.rowMarkerChecked;
if (checked !== true && c.headerRowMarkerAlwaysVisible !== true) {
ctx.globalAlpha = hoverAmount;
Expand Down
1 change: 1 addition & 0 deletions packages/core/test/data-grid-lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function makeCol(title: string, sourceIndex: number, sticky: boolean, width: num
grow: undefined,
headerRowMarkerAlwaysVisible: undefined,
headerRowMarkerTheme: undefined,
headerRowMarkerDisabled: undefined,
hasMenu: undefined,
icon: undefined,
id: undefined,
Expand Down

0 comments on commit 12883ca

Please sign in to comment.