refactor(ui): revert selection UI mechanism to use precise CSS selectors
This commit is contained in:
parent
8ba9480bb0
commit
1d7b429b14
@ -31,31 +31,24 @@ export const createSelectionManager = (container, state) => {
|
||||
const body = container.querySelector('.dt-body');
|
||||
if (!body) return;
|
||||
|
||||
// Fast path: Use children instead of querySelectorAll
|
||||
const nodes = body.children;
|
||||
for (let r = 0; r < nodes.length; r++) {
|
||||
const rowNode = nodes[r];
|
||||
if (!rowNode.classList.contains('dt-body-row')) continue;
|
||||
|
||||
const rowNodes = body.querySelectorAll('.dt-body-row');
|
||||
rowNodes.forEach(rowNode => {
|
||||
const absoluteRow = (rowNode._ref?.rIdx ?? -1) + state._listStartIndex;
|
||||
const cells = rowNode.querySelectorAll('.dt-cell');
|
||||
|
||||
if (!hasSelection || absoluteRow < boundMinRow || absoluteRow > boundMaxRow) {
|
||||
// Clear all cells in row without checking individually if possible
|
||||
const cellNodes = rowNode.children;
|
||||
for (let i = 0; i < cellNodes.length; i++) {
|
||||
cellNodes[i].classList.remove('dt-cell-selected');
|
||||
}
|
||||
continue;
|
||||
cells.forEach(cell => cell.classList.remove('dt-cell-selected'));
|
||||
return;
|
||||
}
|
||||
|
||||
const cellNodes = rowNode.children;
|
||||
for (let i = 0; i < cellNodes.length; i++) {
|
||||
const isSelected = isCellSelected(absoluteRow, i);
|
||||
const cell = cellNodes[i];
|
||||
if (isSelected) cell.classList.add('dt-cell-selected');
|
||||
else cell.classList.remove('dt-cell-selected');
|
||||
}
|
||||
}
|
||||
cells.forEach((cell, cIdx) => {
|
||||
if (isCellSelected(absoluteRow, cIdx)) {
|
||||
cell.classList.add('dt-cell-selected');
|
||||
} else {
|
||||
cell.classList.remove('dt-cell-selected');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const updateStatus = () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user