-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add type-ahead to assign tester dropdown #1095
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -113,9 +113,33 @@ const AssignTesterDropdown = ({ | |||||
const clearAriaLiveRegion = () => { | ||||||
setAlertMessage(''); | ||||||
}; | ||||||
|
||||||
const handleKeyDown = event => { | ||||||
const { key } = event; | ||||||
if (key.match(/[a-z]/)) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
While there are none currently tracked by the app, I've come to find out GitHub usernames can begin with a number, so just to be safe. Uppercase is there as well in case one is holding |
||||||
const container = event.target.closest('[role=menu]'); | ||||||
const matchingMenuItem = Array.from(container.children).find( | ||||||
menuItem => { | ||||||
return menuItem.innerText | ||||||
.trim() | ||||||
.toLowerCase() | ||||||
.startsWith(key); | ||||||
} | ||||||
); | ||||||
|
||||||
if (matchingMenuItem) { | ||||||
matchingMenuItem.focus(); | ||||||
} | ||||||
} | ||||||
}; | ||||||
|
||||||
return ( | ||||||
<LoadingStatus message={loadingMessage}> | ||||||
<Dropdown focusFirstItemOnShow aria-label="Assign testers menu"> | ||||||
<Dropdown | ||||||
focusFirstItemOnShow | ||||||
aria-label="Assign testers menu" | ||||||
onKeyDown={handleKeyDown} | ||||||
> | ||||||
<Dropdown.Toggle | ||||||
ref={dropdownAssignTesterButtonRef} | ||||||
aria-label="Assign testers" | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting!