Skip to content

Commit

Permalink
Merge pull request #7576 from divyanshiGupta/ODC-5281
Browse files Browse the repository at this point in the history
Bug 1908715: Add fix to loop back to last quick-search list item on pressing arrow up key when on top
  • Loading branch information
openshift-merge-robot committed Dec 17, 2020
2 parents 45e7535 + be4de40 commit 56d306f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
var(--pf-c-data-list__item--sm--BorderBottomColor) !important;
}
&__all-items-link {
padding: var(--pf-global--spacer--xs) 0px;
padding: var(--pf-global--spacer--sm) 0px;
text-align: center;
font-size: var(--pf-global--FontSize--md);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const QuickSearchModalBody: React.FC<QuickSearchModalBodyProps> = ({
}, [selectedItem, namespace, searchTerm]);

const selectPrevious = React.useCallback(() => {
const index = getIndexOfSelectedItem();
let index = getIndexOfSelectedItem();
if (index === 0) index = listCatalogItems?.length;
setSelectedItemId(listCatalogItems?.[index - 1]?.uid);
setSelectedItem(listCatalogItems?.[index - 1]);
}, [listCatalogItems, getIndexOfSelectedItem]);
Expand All @@ -101,10 +102,12 @@ const QuickSearchModalBody: React.FC<QuickSearchModalBodyProps> = ({
break;
}
case 'ArrowUp': {
e.preventDefault();
selectPrevious();
break;
}
case 'ArrowDown': {
e.preventDefault();
selectNext();
break;
}
Expand Down

0 comments on commit 56d306f

Please sign in to comment.