Skip to content

Commit 872d6fe

Browse files
fregantesindresorhus
authored andcommitted
Restore file-list highlight when using keyboard navigation (refined-github#1241)
1 parent e4d8dd2 commit 872d6fe

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

source/content.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@
4848
opacity: 0.6;
4949
}
5050

51-
/* Remove annoying hover in the repo file list */
52-
.file-wrap .files .navigation-focus td {
51+
/* For `rgh-no-navigation-highlight` */
52+
.rgh-no-navigation-highlight .list-group-item.navigation-focus, /* Notifications list */
53+
.rgh-no-navigation-highlight .Box-row.navigation-focus, /* Issue list */
54+
.rgh-no-navigation-highlight .navigation-focus td { /* File list */
5355
background: none !important;
5456
}
5557

source/content.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import closeOutOfViewModals from './features/close-out-of-view-modals';
7373
import addScopedSearchOnUserProfile from './features/add-scoped-search-on-user-profile';
7474
import monospaceTextareas from './features/monospace-textareas';
7575
import improveShortcutHelp from './features/improve-shortcut-help';
76+
import hideNavigationHoverHighlight from './features/hide-navigation-hover-highlight';
7677
import displayIssueSuggestions from './features/display-issue-suggestions';
7778
import addPullRequestHotkey from './features/add-pull-request-hotkey';
7879
import openSelectionInNewTab from './features/add-selection-in-new-tab';
@@ -130,6 +131,7 @@ async function init() {
130131
enableFeature(focusConfirmationButtons);
131132
enableFeature(addKeyboardShortcutsToCommentFields);
132133
enableFeature(addConfirmationToCommentCancellation);
134+
enableFeature(hideNavigationHoverHighlight);
133135
enableFeature(monospaceTextareas);
134136
enableFeature(openSelectionInNewTab);
135137

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
Some lists like notifications, file lists, and issue lists,
3+
are highlighted as you move the mouse over them. This highlight
4+
is useful when navigating via the keyboard (j/k), but annoying
5+
when just moving the mouse around.
6+
7+
This feature will hide the highlight until the first keyboard
8+
navigation, then it will be displayed until the next full reload.
9+
*/
10+
const className = 'rgh-no-navigation-highlight';
11+
12+
export default function () {
13+
document.body.classList.add(className);
14+
document.body.addEventListener('navigation:keydown', () => {
15+
document.body.classList.remove(className);
16+
}, {once: true});
17+
}

0 commit comments

Comments
 (0)