Skip to content

Commit

Permalink
Don't draw focus background if focus ring is disabled (#886)
Browse files Browse the repository at this point in the history
  • Loading branch information
jassmith committed Jan 29, 2024
1 parent f731d0d commit ff67bc2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions packages/core/src/internal/data-grid/render/data-grid-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,20 @@ function cellIsInRect(location: Item, cell: InnerGridCell, rect: Rectangle): boo
);
}

export function cellIsInRange(location: Item, cell: InnerGridCell, selection: GridSelection): number {
export function cellIsInRange(
location: Item,
cell: InnerGridCell,
selection: GridSelection,
includeSingleSelection: boolean
): number {
let result = 0;
if (selection.current === undefined) return result;

if (cellIsInRect(location, cell, selection.current.range)) result++;
const range = selection.current.range;

if ((includeSingleSelection || range.height * range.width > 1) && cellIsInRect(location, cell, range)) {
result++;
}
for (const r of selection.current.rangeStack) {
if (cellIsInRect(location, cell, r)) {
result++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ export function drawCells(
ctx.beginPath();

const isSelected = cellIsSelected(cellIndex, cell, selection);
let accentCount = cellIsInRange(cellIndex, cell, selection);
let accentCount = cellIsInRange(cellIndex, cell, selection, drawFocus);
const spanIsHighlighted =
cell.span !== undefined &&
selection.columns.some(
index => cell.span !== undefined && index >= cell.span[0] && index <= cell.span[1] //alloc
);
if (isSelected && !isFocused && drawFocus) {
accentCount = 0;
} else if (isSelected) {
} else if (isSelected && drawFocus) {
accentCount = Math.max(accentCount, 1);
}
if (spanIsHighlighted) {
Expand Down

0 comments on commit ff67bc2

Please sign in to comment.