Skip to content

Commit ff67bc2

Browse files
authored
Don't draw focus background if focus ring is disabled (#886)
1 parent f731d0d commit ff67bc2

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/core/src/internal/data-grid/render/data-grid-lib.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,20 @@ function cellIsInRect(location: Item, cell: InnerGridCell, rect: Rectangle): boo
115115
);
116116
}
117117

118-
export function cellIsInRange(location: Item, cell: InnerGridCell, selection: GridSelection): number {
118+
export function cellIsInRange(
119+
location: Item,
120+
cell: InnerGridCell,
121+
selection: GridSelection,
122+
includeSingleSelection: boolean
123+
): number {
119124
let result = 0;
120125
if (selection.current === undefined) return result;
121126

122-
if (cellIsInRect(location, cell, selection.current.range)) result++;
127+
const range = selection.current.range;
128+
129+
if ((includeSingleSelection || range.height * range.width > 1) && cellIsInRect(location, cell, range)) {
130+
result++;
131+
}
123132
for (const r of selection.current.rangeStack) {
124133
if (cellIsInRect(location, cell, r)) {
125134
result++;

packages/core/src/internal/data-grid/render/data-grid-render.cells.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,15 @@ export function drawCells(
274274
ctx.beginPath();
275275

276276
const isSelected = cellIsSelected(cellIndex, cell, selection);
277-
let accentCount = cellIsInRange(cellIndex, cell, selection);
277+
let accentCount = cellIsInRange(cellIndex, cell, selection, drawFocus);
278278
const spanIsHighlighted =
279279
cell.span !== undefined &&
280280
selection.columns.some(
281281
index => cell.span !== undefined && index >= cell.span[0] && index <= cell.span[1] //alloc
282282
);
283283
if (isSelected && !isFocused && drawFocus) {
284284
accentCount = 0;
285-
} else if (isSelected) {
285+
} else if (isSelected && drawFocus) {
286286
accentCount = Math.max(accentCount, 1);
287287
}
288288
if (spanIsHighlighted) {

0 commit comments

Comments
 (0)