Skip to content

Commit 33fdc6d

Browse files
authored
Change integrate input behaviour with single result (#942)
1 parent 3babe21 commit 33fdc6d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

static/js/integrations-filters.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,27 @@ function handleAlphaFilterClick(event) {
5151
filterGridItems(); // Apply filter based on the selected first letter
5252
}
5353

54+
// Function to handle key down events
55+
function keyDownHandler(event) {
56+
switch (event.key) {
57+
case "Enter":
58+
visibleLibrariesAndTools = document.querySelectorAll("article.flex.flex-col.gap-2.transition.relative:not([style='display: none;'])")
59+
if (visibleLibrariesAndTools.length == 1) {
60+
event.preventDefault();
61+
libraryAndToolHref = visibleLibrariesAndTools[0].getElementsByTagName("a")[0].href
62+
window.location.assign(libraryAndToolHref)
63+
};
64+
default:
65+
return;
66+
}
67+
};
5468

5569
// Listen for change events on the group filter
5670
groupFilter.addEventListener('change', filterGridItems);
5771

5872
// Listen for input events on the name filter
5973
nameFilter.addEventListener('input', filterGridItems);
74+
nameFilter.addEventListener('keydown', keyDownHandler);
6075

6176
// Attach click event listeners to alpha filter buttons
6277
alphaFilterButtons.forEach(button => {

0 commit comments

Comments
 (0)