Skip to content

Commit

Permalink
Menu: Fix typeahead with leading visuals (#1914)
Browse files Browse the repository at this point in the history
* Trim textContent to ignore leading visual

* Create slimy-garlics-wash.md

* Menu → ActionMenu
  • Loading branch information
siddharthkp authored Mar 2, 2022
1 parent 0256a5f commit b651d70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/slimy-garlics-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

ActionMenu: Fix typeahead with leading visuals
2 changes: 1 addition & 1 deletion src/hooks/useTypeaheadFocus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const useTypeaheadFocus = (open: boolean, providedRef?: React.RefObject<H

const focusNextMatch = () => {
const itemsStartingWithKey = focusableItems.filter(item => {
return item.textContent?.toLowerCase().startsWith(query)
return item.textContent?.toLowerCase().trim().startsWith(query)
})

const currentActiveIndex = itemsStartingWithKey.indexOf(activeElement)
Expand Down

0 comments on commit b651d70

Please sign in to comment.