Skip to content

Commit

Permalink
Merge pull request #514 from mozilla-iam/enter-link
Browse files Browse the repository at this point in the history
Activate tile link on searchbox enter key if only one visible
  • Loading branch information
dividehex authored Aug 15, 2024
2 parents 5de79c6 + 798dcb0 commit 67c46cc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion dashboard/static/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ $(document).ready(function(){
'use strict';

// This is the js that powers the search box
$(':input[name=filter]').on('input', function() {
$(':input[name=filter]')
.on('input', function() {
// Get value just typed into textbox -- see .toLowerCase()
var val = this.value.toLowerCase();

Expand All @@ -22,6 +23,15 @@ $(document).ready(function(){
})
// Fade those out
.fadeOut();
})
.on('keypress', function (ev) {
if (ev.key === 'Enter') {
const tiles = $('#app-grid .app-tile:visible');
if (tiles.length === 1) {
// If only one tile is visible, open its link on Enter
window.open(tiles[0].href, '_blank');
}
}
});

// Search input: Highlight, Align, Focus
Expand Down

0 comments on commit 67c46cc

Please sign in to comment.