Skip to content

Commit

Permalink
fix: search (ctrl + K) and keyboard arrow issue (RocketChat#29538)
Browse files Browse the repository at this point in the history
Co-authored-by: Hugo Costa <[email protected]>
  • Loading branch information
AyushKaithwas and hugocostadev authored Jun 14, 2023
1 parent 27a2f98 commit 9b89995
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/search-shortcut.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed Search Shortcut (ctrl + K) and keyboard navigation and selection
10 changes: 8 additions & 2 deletions apps/meteor/client/sidebar/search/SearchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,15 @@ const SearchList = forwardRef(function SearchList({ onClose }: SearchListProps,
let nextSelectedElement = null;

if (dir === 'up') {
nextSelectedElement = (selectedElement.current?.parentElement?.previousSibling as HTMLElement).querySelector('a');
const potentialElement = selectedElement.current?.parentElement?.previousSibling as HTMLElement;
if (potentialElement) {
nextSelectedElement = potentialElement.querySelector('a');
}
} else {
nextSelectedElement = (selectedElement.current?.parentElement?.nextSibling as HTMLElement).querySelector('a');
const potentialElement = selectedElement.current?.parentElement?.nextSibling as HTMLElement;
if (potentialElement) {
nextSelectedElement = potentialElement.querySelector('a');
}
}

if (nextSelectedElement) {
Expand Down

0 comments on commit 9b89995

Please sign in to comment.