|
1 | 1 | import React, { useEffect, useState } from 'react'; |
2 | 2 | import { Button, ComboBox, FieldError, Input, Label, ListBox, ListBoxItem, Popover } from 'react-aria-components'; |
3 | 3 |
|
| 4 | +import { fuzzyMatch } from '~/common/misc'; |
| 5 | + |
4 | 6 | import { getAppWebsiteBaseURL } from '../../../common/constants'; |
5 | 7 | import { isGitHubAppUserToken } from '../github-app-config-link'; |
6 | 8 | import { Icon } from '../icon'; |
@@ -89,6 +91,9 @@ export const GitHubRepositorySelect = ({ |
89 | 91 | }))} |
90 | 92 | onSelectionChange={key => setSelectedRepository(repositories.find(r => r.clone_url === key) || null)} |
91 | 93 | menuTrigger="focus" |
| 94 | + defaultFilter={(repoName: string, inputValue: string) => |
| 95 | + Boolean(fuzzyMatch(inputValue, repoName, { splitSpace: true, loose: false })?.indexes) |
| 96 | + } |
92 | 97 | > |
93 | 98 | <div className="flex w-full items-center gap-2"> |
94 | 99 | <div className="group flex h-(--line-height-xs) flex-1 items-center gap-2 rounded-xs border border-solid border-(--hl-sm) bg-(--color-bg) text-(--color-font) transition-colors focus:ring-1 focus:ring-(--hl-md) focus:outline-hidden"> |
@@ -141,7 +146,8 @@ export const GitHubRepositorySelect = ({ |
141 | 146 | {isDisabled && <Icon icon="lock" className="group-aria-disabled:opacity-30" />} |
142 | 147 | <span className="truncate group-aria-disabled:opacity-30">{item.name}</span> |
143 | 148 | {isDisabled && ( |
144 | | - <span className="hidden rounded border border-solid border-(--hl-xl) px-2 py-1 text-(--color-font) group-hover:inline-block"> |
| 149 | + /* If you use hidden here, if the drop down is a long list and you scroll to the disabled item and hover on it, the scroll bar will scroll to the top. So we use invisible instead */ |
| 150 | + <span className="invisible rounded border border-solid border-(--hl-xl) px-2 py-1 text-(--color-font) group-hover:visible"> |
145 | 151 | Already connected to: {allConnectedRepoURIProjectNameMap[item.id]} |
146 | 152 | </span> |
147 | 153 | )} |
|
0 commit comments