Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a problem with keyboard navigation and scrolling on window-scrolled instances. #10655

Merged
merged 5 commits into from Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changelogs/10655.json
@@ -0,0 +1,8 @@
{
"issuesOrigin": "private",
"title": "Fixed a problem where in specific situations the table was not being scrolled after navigating it with the keyboard, fixed an issue with the drag-to-scroll functionality not working for window-scrolled instances.",
"type": "fixed",
"issueOrPR": 10655,
"breaking": false,
"framework": "none"
}
71 changes: 2 additions & 69 deletions handsontable/src/3rdparty/walkontable/src/scroll.js
Expand Up @@ -177,42 +177,7 @@ class Scroll {
* @returns {number}
*/
getFirstVisibleRow() {
const {
topOverlay,
wtTable,
wtViewport,
totalRows,
fixedRowsTop,
rootWindow,
} = this.dataAccessObject;

let firstVisibleRow = wtTable.getFirstVisibleRow();

if (topOverlay.mainTableScrollableElement === rootWindow) {
const rootElementOffset = offset(wtTable.wtRootElement);
const totalTableHeight = innerHeight(wtTable.hider);
const windowHeight = innerHeight(rootWindow);
const windowScrollTop = getScrollTop(rootWindow, rootWindow);

// Only calculate firstVisibleRow when table didn't filled (from up) whole viewport space
if (rootElementOffset.top + totalTableHeight - windowHeight <= windowScrollTop) {
let rowsHeight = wtViewport.getColumnHeaderHeight();

rowsHeight += topOverlay.sumCellSizes(0, fixedRowsTop);

for (let row = totalRows; row > 0; row--) {
rowsHeight += topOverlay.sumCellSizes(row - 1, row);

if (rootElementOffset.top + totalTableHeight - rowsHeight <= windowScrollTop) {
// Return physical row + 1
firstVisibleRow = row;
break;
}
}
}
}

return firstVisibleRow;
return this.dataAccessObject.wtTable.getFirstVisibleRow();
}

/**
Expand Down Expand Up @@ -260,39 +225,7 @@ class Scroll {
* @returns {number}
*/
getFirstVisibleColumn() {
const {
inlineStartOverlay,
wtTable,
wtViewport,
totalColumns,
rootWindow,
} = this.dataAccessObject;

let firstVisibleColumn = wtTable.getFirstVisibleColumn();

if (inlineStartOverlay.mainTableScrollableElement === rootWindow) {
const rootElementOffset = offset(wtTable.wtRootElement);
const totalTableWidth = innerWidth(wtTable.hider);
const windowWidth = innerWidth(rootWindow);
const windowScrollLeft = Math.abs(getScrollLeft(rootWindow, rootWindow));

// Only calculate firstVisibleColumn when table didn't filled (from left) whole viewport space
if (rootElementOffset.left + totalTableWidth - windowWidth <= windowScrollLeft) {
let columnsWidth = wtViewport.getRowHeaderWidth();

for (let column = totalColumns; column > 0; column--) {
columnsWidth += inlineStartOverlay.sumCellSizes(column - 1, column);

if (rootElementOffset.left + totalTableWidth - columnsWidth <= windowScrollLeft) {
// Return physical column + 1
firstVisibleColumn = column;
break;
}
}
}
}

return firstVisibleColumn;
return this.dataAccessObject.wtTable.getFirstVisibleColumn();
}

/**
Expand Down