Skip to content

Commit

Permalink
Added tab indexing to table column dividers to allow keyboard resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
jschick04 authored and bill-long committed Aug 20, 2024
1 parent afa2328 commit 039110a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/EventLogExpert/wwwroot/js/event_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ window.enableColumnResize = (table) => {
divider.classList.add("table-divider");

column.appendChild(divider);
divider.tabIndex = 0;

const mouseMoveHandler = function(e) {
const distance = e.clientX - x;
Expand All @@ -50,7 +51,19 @@ window.enableColumnResize = (table) => {
document.addEventListener("mouseup", mouseUpHandler);
};

const keyboardResizeHandler = function (e) {
const styles = window.getComputedStyle(column);
w = parseInt(styles.width, 10);

if (e.key === "ArrowRight") {
column.style.width = `${w + 10}px`;
} else if (e.key === "ArrowLeft") {
column.style.width = `${w - 10}px`;
}
};

divider.addEventListener("mousedown", mouseDownHandler);
divider.addEventListener("keydown", keyboardResizeHandler);
};

for (let i = 0; i < columns.length - 1; i++) {
Expand Down

0 comments on commit 039110a

Please sign in to comment.