Fix overflow of quick search results with long repository names (#1739)

This commit is contained in:
Sebastian Sdorra
2021-07-26 13:50:24 +02:00
committed by GitHub
parent 903285ad96
commit f2cc9f67ac
2 changed files with 13 additions and 4 deletions

View File

@@ -0,0 +1,2 @@
- type: Fixed
description: Fix overflow of quick search results with long repository names ([#1739](https://github.com/scm-manager/scm-manager/pull/1739))

View File

@@ -101,6 +101,10 @@ const ResultHeading = styled.div`
padding: 0.375rem 0.5rem; padding: 0.375rem 0.5rem;
`; `;
const DropdownMenu = styled.div`
max-width: 20rem;
`;
const Hits: FC<HitsProps> = ({ hits, index, clear }) => { const Hits: FC<HitsProps> = ({ hits, index, clear }) => {
const id = useCallback(namespaceAndName, [hits]); const id = useCallback(namespaceAndName, [hits]);
const [t] = useTranslation("commons"); const [t] = useTranslation("commons");
@@ -115,7 +119,10 @@ const Hits: FC<HitsProps> = ({ hits, index, clear }) => {
{hits.map((hit, idx) => ( {hits.map((hit, idx) => (
<div key={id(hit)} onMouseDown={(e) => e.preventDefault()} onClick={clear}> <div key={id(hit)} onMouseDown={(e) => e.preventDefault()} onClick={clear}>
<Link <Link
className={classNames("dropdown-item", "has-text-weight-medium", { "is-active": idx === index })} className={classNames("dropdown-item", "has-text-weight-medium", "is-ellipsis-overflow", {
"is-active": idx === index,
})}
title={id(hit)}
to={`/repo/${id(hit)}`} to={`/repo/${id(hit)}`}
> >
{id(hit)} {id(hit)}
@@ -195,7 +202,7 @@ const useShowResultsOnFocus = () => {
showResults, showResults,
onClick: (e: MouseEvent<HTMLInputElement>) => e.stopPropagation(), onClick: (e: MouseEvent<HTMLInputElement>) => e.stopPropagation(),
onFocus: () => setShowResults(true), onFocus: () => setShowResults(true),
onBlur: () => setShowResults(false) onBlur: () => setShowResults(false),
}; };
}; };
@@ -234,10 +241,10 @@ const OmniSearch: FC = () => {
</span> </span>
)} )}
</div> </div>
<div className="dropdown-menu"> <DropdownMenu className="dropdown-menu">
{error ? <SearchErrorNotification error={error} /> : null} {error ? <SearchErrorNotification error={error} /> : null}
{!error && data ? <Hits clear={clearQuery} index={index} hits={data._embedded.hits} /> : null} {!error && data ? <Hits clear={clearQuery} index={index} hits={data._embedded.hits} /> : null}
</div> </DropdownMenu>
</div> </div>
</div> </div>
</Field> </Field>