Skip to content

Commit eb6902f

Browse files
committed
Fix bug related to arrow key navigation
1 parent 439806e commit eb6902f

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

InteractiveHtmlBom/ibom.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -285,39 +285,45 @@ function highlightPreviousRow() {
285285
highlightHandlers[highlightHandlers.length - 1].handler();
286286
return;
287287
}
288-
for (var i = 0; i < highlightHandlers.length - 1; i++) {
289-
if (highlightHandlers[i + 1].id == currentHighlightedRowId) {
290-
highlightHandlers[i].handler();
291-
break;
292-
}
293-
}
294288
if (highlightHandlers.length > 1 &&
295289
highlightHandlers[0].id == currentHighlightedRowId) {
296290
highlightHandlers[highlightHandlers.length - 1].handler();
291+
} else {
292+
for (var i = 0; i < highlightHandlers.length - 1; i++) {
293+
if (highlightHandlers[i + 1].id == currentHighlightedRowId) {
294+
highlightHandlers[i].handler();
295+
break;
296+
}
297+
}
297298
}
298-
document.getElementById(currentHighlightedRowId).scrollIntoView(
299-
{behavior: "smooth", block: "center", inline: "nearest"}
300-
);
299+
document.getElementById(currentHighlightedRowId).scrollIntoView({
300+
behavior: "smooth",
301+
block: "center",
302+
inline: "nearest"
303+
});
301304
}
302305

303306
function highlightNextRow() {
304307
if (!currentHighlightedRowId) {
305308
highlightHandlers[0].handler();
306309
return;
307310
}
308-
for (var i = 1; i < highlightHandlers.length; i++) {
309-
if (highlightHandlers[i - 1].id == currentHighlightedRowId) {
310-
highlightHandlers[i].handler();
311-
break;
312-
}
313-
}
314311
if (highlightHandlers.length > 1 &&
315312
highlightHandlers[highlightHandlers.length - 1].id == currentHighlightedRowId) {
316313
highlightHandlers[0].handler();
314+
} else {
315+
for (var i = 1; i < highlightHandlers.length; i++) {
316+
if (highlightHandlers[i - 1].id == currentHighlightedRowId) {
317+
highlightHandlers[i].handler();
318+
break;
319+
}
320+
}
317321
}
318-
document.getElementById(currentHighlightedRowId).scrollIntoView(
319-
{behavior: "smooth", block: "center", inline: "nearest"}
320-
);
322+
document.getElementById(currentHighlightedRowId).scrollIntoView({
323+
behavior: "smooth",
324+
block: "center",
325+
inline: "nearest"
326+
});
321327
}
322328

323329
function populateBomTable() {

0 commit comments

Comments
 (0)