fix(search): input base styles

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2023-05-18 13:00:37 +02:00
committed by Carlos Esteban Lopez
parent 2f660eb573
commit ba261f9dcd
7 changed files with 104 additions and 151 deletions
@@ -21,20 +21,10 @@ import {
SearchContextProvider,
useSearch,
} from '@backstage/plugin-search-react';
import { makeStyles, Paper } from '@material-ui/core';
import React, { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { TechDocsSearchResultListItem } from './TechDocsSearchResultListItem';
const useStyles = makeStyles(theme => ({
root: {
width: '100%',
},
bar: {
padding: theme.spacing(1),
},
}));
/**
* Props for {@link TechDocsSearch}
*
@@ -75,7 +65,6 @@ const TechDocsSearchBar = (props: TechDocsSearchProps) => {
setFilters,
result: { loading, value: searchVal },
} = useSearch();
const classes = useStyles();
const [options, setOptions] = useState<any[]>([]);
useEffect(() => {
let mounted = true;
@@ -117,43 +106,40 @@ const TechDocsSearchBar = (props: TechDocsSearchProps) => {
};
return (
<Paper className={classes.bar} variant="outlined">
<SearchAutocomplete
classes={{ root: classes.root }}
data-testid="techdocs-search-bar"
size="small"
open={open}
getOptionLabel={() => ''}
filterOptions={x => {
return x; // This is needed to get renderOption to be called after options change. Bug in material-ui?
}}
onClose={() => {
setOpen(false);
}}
onFocus={() => {
setOpen(true);
}}
onChange={handleSelection}
blurOnSelect
noOptionsText="No results found"
value={null}
options={options}
renderOption={({ document, highlight }) => (
<TechDocsSearchResultListItem
result={document}
lineClamp={3}
asListItem={false}
asLink={false}
title={document.title}
highlight={highlight}
/>
)}
loading={loading}
inputDebounceTime={debounceTime}
inputPlaceholder={`Search ${entityTitle || entityId.name} docs`}
freeSolo={false}
/>
</Paper>
<SearchAutocomplete
data-testid="techdocs-search-bar"
size="small"
open={open}
getOptionLabel={() => ''}
filterOptions={x => {
return x; // This is needed to get renderOption to be called after options change. Bug in material-ui?
}}
onClose={() => {
setOpen(false);
}}
onFocus={() => {
setOpen(true);
}}
onChange={handleSelection}
blurOnSelect
noOptionsText="No results found"
value={null}
options={options}
renderOption={({ document, highlight }) => (
<TechDocsSearchResultListItem
result={document}
lineClamp={3}
asListItem={false}
asLink={false}
title={document.title}
highlight={highlight}
/>
)}
loading={loading}
inputDebounceTime={debounceTime}
inputPlaceholder={`Search ${entityTitle || entityId.name} docs`}
freeSolo={false}
/>
);
};