Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Tweak keyboard nav folder selection entry in browser extension

Leendert de Borstc65b3969c31c
diff --git a/apps/browser-extension/src/entrypoints/popup/hooks/useListKeyboardNav.ts b/apps/browser-extension/src/entrypoints/popup/hooks/useListKeyboardNav.ts
index aaff12425..afd79c73e 100644
--- a/apps/browser-extension/src/entrypoints/popup/hooks/useListKeyboardNav.ts
+++ b/apps/browser-extension/src/entrypoints/popup/hooks/useListKeyboardNav.ts
@@ -6,6 +6,7 @@ interface IUseListKeyboardNavParams {
folderCount: number;
itemCount: number;
searchInputRef: RefObject<HTMLInputElement | null>;
+ resetKey: string | null;
onActivateFolder: (index: number) => void;
onActivateItem: (index: number) => void;
onGoBack: () => void;
@@ -29,11 +30,17 @@ const ID_PREFIX = 'kb-nav';
* ← go up one folder (ignored while typing in the search input)
*/
export const useListKeyboardNav = (params: IUseListKeyboardNavParams): IUseListKeyboardNavReturn => {
- const { folderCount, itemCount, searchInputRef, onActivateFolder, onActivateItem, onGoBack, onClearSearch } = params;
+ const { folderCount, itemCount, searchInputRef, resetKey, onActivateFolder, onActivateItem, onGoBack, onClearSearch } = params;
const [activeKind, setActiveKind] = useState<ActiveKind>(null);
const [activeIndex, setActiveIndex] = useState(0);
+ // Reset selection when navigating to a new page/folder so the highlight starts fresh.
+ useEffect(() => {
+ setActiveKind(null);
+ setActiveIndex(0);
+ }, [resetKey]);
+
// Clamp active selection when the underlying lists shrink (e.g. user types into search).
useEffect(() => {
if (activeKind === 'item') {
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx
index 6ec8ab6f3..641827436 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx
@@ -732,6 +732,7 @@ const ItemsList: React.FC = () => {
folderCount: folders.length,
itemCount: sortedItems.length,
searchInputRef,
+ resetKey: currentFolderId,
onActivateFolder: handleActivateFolder,
onActivateItem: handleActivateItem,
onGoBack: handleGoBack,