Skip to content
Merged
Changes from 3 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
30 changes: 21 additions & 9 deletions src/BootstrapBlazor/Components/Table/Table.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,19 @@ const setExcelKeyboardListener = table => {
const setFocus = target => {
const handler = setTimeout(function () {
clearTimeout(handler);
target.focus();
target.select();
if (target.focus) {
target.focus();
}
if (target.select) {
target.select();
}
}, 10);
}

const activeCell = (cells, index) => {
let ret = false;
const td = cells[index];
const target = td.querySelector('input.form-control:not([readonly])');
const target = td.querySelector('.form-control:not([readonly])');
if (target) {
setFocus(target);
ret = true;
Expand Down Expand Up @@ -425,22 +429,30 @@ const setExcelKeyboardListener = table => {
}
}
else if (keyCode === KeyCodes.UP_ARROW) {
cells = tr.previousElementSibling && tr.previousElementSibling.children;
if (cells) {
while (index < cells.length) {
let nextRow = tr.previousElementSibling;
while (nextRow) {
cells = nextRow.children;
if (cells) {
if (activeCell(cells, index)) {
break;
}
else {
nextRow = nextRow.previousElementSibling;
}
}
}
}
else if (keyCode === KeyCodes.DOWN_ARROW) {
cells = tr.nextElementSibling && tr.nextElementSibling.children;
if (cells) {
while (index < cells.length) {
let nextRow = tr.nextElementSibling;
while (nextRow) {
cells = nextRow.children;
if (cells) {
if (activeCell(cells, index)) {
break;
}
else {
nextRow = nextRow.nextElementSibling;
}
}
}
}
Expand Down