Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/core/src/internal/data-grid/render/data-grid-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ export function gridSelectionHasItem(sel: GridSelection, item: Item): boolean {
if (sel.columns.hasIndex(col) || sel.rows.hasIndex(row)) return true;
if (sel.current !== undefined) {
if (itemsAreEqual(sel.current.cell, item)) return true;
const toCheck = [sel.current.range, ...sel.current.rangeStack]; // FIXME: pointless alloc
for (const r of toCheck) {
// dont we have a function for this?
if (col >= sel.current.range.x && col < sel.current.range.x + sel.current.range.width && row >= sel.current.range.y && row < sel.current.range.y + sel.current.range.height) return true;
Copy link

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This line is quite long and complex with multiple property accesses. Consider extracting variables for sel.current.range and the boundary calculations to improve readability.

Suggested change
if (col >= sel.current.range.x && col < sel.current.range.x + sel.current.range.width && row >= sel.current.range.y && row < sel.current.range.y + sel.current.range.height) return true;
const range = sel.current.range;
const xMin = range.x;
const xMax = range.x + range.width;
const yMin = range.y;
const yMax = range.y + range.height;
if (col >= xMin && col < xMax && row >= yMin && row < yMax) return true;

Copilot uses AI. Check for mistakes.
for (const r of sel.current.rangeStack) {
if (col >= r.x && col < r.x + r.width && row >= r.y && row < r.y + r.height) return true;
}
}
Expand Down