Skip to content

Commit

Permalink
Fix key navigation on test details
Browse files Browse the repository at this point in the history
When viewing a test live and test module details are added to the page
dynamically, then the key navigation breaks. It skips steps instead of
just selecting the next/previous step. This is because the event handler
is registered multiple times. This change fixes the issue by making sure
the event handler is only registered once.

Related ticket: https://progress.opensuse.org/issues/113468
  • Loading branch information
Martchus authored and perlpunk committed Sep 21, 2023
1 parent d2a7168 commit f1b115c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions assets/javascripts/test_result.js
Expand Up @@ -644,16 +644,20 @@ function renderTestModules(response) {
setCurrentPreviewFromStepLinkIfPossible($("[href='" + hash + "'], [data-href='" + hash + "']"));
}

// setup keyboard navigation through test details
$(window).keydown(handleKeyDownOnTestDetails);

// ensure the size of the preview container is adjusted when the window size changes
$(window).resize(function () {
const currentPreview = $('.current_preview');
if (currentPreview.length) {
setCurrentPreview($('.current_preview'), true);
}
});
// setup event handlers for the window
if (!this.hasWindowEventHandlers) {
// setup keyboard navigation through test details
$(window).keydown(handleKeyDownOnTestDetails);

// ensure the size of the preview container is adjusted when the window size changes
$(window).resize(function () {
const currentPreview = $('.current_preview');
if (currentPreview.length) {
setCurrentPreview($('.current_preview'), true);
}
});
this.hasWindowEventHandlers = true;
}

// setup result filter, define function to apply filter changes
const detailsFilter = $('#details-filter');
Expand Down

0 comments on commit f1b115c

Please sign in to comment.