{
expect(result).toMatchSnapshot()
})
+ it('should render with a 300px max height', () => {
+ const options = {
+ onSelect: () => `''`,
+ loading: false,
+ value: [],
+ maxHeight: 300,
+ }
+
+ const input = {
+ onChange: () => `''`,
+ onSearch: () => `''`,
+ onClear: () => `''`,
+ placeholder: '',
+ value: '',
+ }
+
+ const { asFragment } = render(
+
+ )
+
+ const result = asFragment()
+
+ expect(result).toMatchSnapshot()
+ })
+
it('should render with a regular size bar', () => {
const options = {
onSelect: () => `''`,
@@ -108,7 +133,7 @@ describe('AutocompleteInput', () => {
onSelect: () => `''`,
loading: false,
value: [],
- size: 'medium',
+ size: 'regular',
}
const input = {
diff --git a/react/components/AutocompleteInput/index.tsx b/react/components/AutocompleteInput/index.tsx
index 7f985935e..0979950f6 100644
--- a/react/components/AutocompleteInput/index.tsx
+++ b/react/components/AutocompleteInput/index.tsx
@@ -9,6 +9,7 @@ import Option, {
getTermFromOption,
} from './Option'
import SearchInput from './SearchInput'
+import styles from './autocomplete.css'
const propTypes = {
/** Input props. All HTMLInput props can be added too */
@@ -92,6 +93,11 @@ const propTypes = {
* It can be a warning, an error, or a hint about the options.
*/
customMessage: PropTypes.node,
+ /**
+ * Max height value for options dropdown.
+ * `fit-content` is the default value.
+ */
+ maxHeight: PropTypes.number,
}).isRequired,
}
@@ -124,6 +130,7 @@ const AutocompleteInput: React.FunctionComponent
= ({
icon,
size,
customMessage,
+ maxHeight = 'fit-content',
},
}) => {
const [term, setTerm] = useState(value || '')
@@ -261,7 +268,7 @@ const AutocompleteInput: React.FunctionComponent = ({
const errorStyle = error || Boolean(errorMessage)
return (
-
+
= ({
/>
{popoverOpened ? (
-
+
{renderOptions()}
{loading && (