Skip to content

Commit c9fb3c4

Browse files
ayusharmajuanpicado
authored andcommitted
fix: search suggestion container height (conventional-changelog#54)
* fix: search suggestion container height * fix: updates snapshot
1 parent 3d752e0 commit c9fb3c4

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/webui/components/AutoComplete/index.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import type { Node } from 'react';
88
import Autosuggest from 'react-autosuggest';
99
import match from 'autosuggest-highlight/match';
1010
import parse from 'autosuggest-highlight/parse';
11-
import Paper from '@material-ui/core/Paper';
1211
import MenuItem from '@material-ui/core/MenuItem';
1312

1413
import { fontWeight } from '../../utils/styles/sizes';
15-
import { Wrapper, InputField } from './styles';
14+
import { Wrapper, InputField, SuggestionContainer } from './styles';
1615
import { IProps } from './types';
1716

1817
const renderInputComponent = (inputProps): Node => {
@@ -110,12 +109,12 @@ const AutoComplete = ({
110109
// this format avoid arrow function eslint rule
111110
function renderSuggestionsContainer({ containerProps, children, query }) {
112111
return (
113-
<Paper {...containerProps} square={true}>
112+
<SuggestionContainer {...containerProps} square={true}>
114113
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}
115114
{suggestionsLoading && query && renderMessage(SUGGESTIONS_RESPONSE.LOADING)}
116115
{suggestionsError && renderMessage(SUGGESTIONS_RESPONSE.FAILURE)}
117116
{children}
118-
</Paper>
117+
</SuggestionContainer>
119118
);
120119
}
121120

src/webui/components/AutoComplete/styles.js

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import React from 'react';
77
import styled, { css } from 'react-emotion';
8+
import Paper from '@material-ui/core/Paper';
89

910
import TextField from '../TextField';
1011
import { IInputField } from './types';
@@ -50,3 +51,10 @@ export const InputField = ({ color, ...others }: IInputField) => (
5051
}}
5152
/>
5253
);
54+
55+
export const SuggestionContainer = styled(Paper)`
56+
&& {
57+
max-height: 500px;
58+
overflow-y: scroll;
59+
}
60+
`;
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`<Search /> component test should load the component in default state 1`] = `"<div class=\\"css-1crzyyo e18292mt0\\"><div role=\\"combobox\\" aria-haspopup=\\"listbox\\" aria-owns=\\"react-autowhatever-1\\" aria-expanded=\\"false\\" class=\\"react-autosuggest__container\\"><div class=\\"MuiFormControl-root-1 MuiFormControl-fullWidth-4 react-autosuggest__input\\" aria-autocomplete=\\"list\\" aria-controls=\\"react-autowhatever-1\\"><div class=\\"MuiInputBase-root-18 MuiInput-root-5 css-n9ojyg MuiInput-underline-9 MuiInputBase-fullWidth-27 MuiInput-fullWidth-12 MuiInputBase-formControl-19 MuiInput-formControl-6 MuiInputBase-adornedStart-22\\"><div class=\\"MuiInputAdornment-root-35 MuiInputAdornment-positionStart-37\\" style=\\"color: rgb(255, 255, 255);\\"><svg class=\\"MuiSvgIcon-root-40\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></div><input aria-invalid=\\"false\\" autocomplete=\\"off\\" class=\\"MuiInputBase-input-28 MuiInput-input-13 css-hodoyq MuiInputBase-inputAdornedStart-33\\" placeholder=\\"Search Packages\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiPaper-root-49 MuiPaper-elevation2-53 react-autosuggest__suggestions-container\\" id=\\"react-autowhatever-1\\" role=\\"listbox\\"></div></div></div>"`;
3+
exports[`<Search /> component test should load the component in default state 1`] = `"<div class=\\"css-1crzyyo e18292mt0\\"><div role=\\"combobox\\" aria-haspopup=\\"listbox\\" aria-owns=\\"react-autowhatever-1\\" aria-expanded=\\"false\\" class=\\"react-autosuggest__container\\"><div class=\\"MuiFormControl-root-1 MuiFormControl-fullWidth-4 react-autosuggest__input\\" aria-autocomplete=\\"list\\" aria-controls=\\"react-autowhatever-1\\"><div class=\\"MuiInputBase-root-18 MuiInput-root-5 css-n9ojyg MuiInput-underline-9 MuiInputBase-fullWidth-27 MuiInput-fullWidth-12 MuiInputBase-formControl-19 MuiInput-formControl-6 MuiInputBase-adornedStart-22\\"><div class=\\"MuiInputAdornment-root-35 MuiInputAdornment-positionStart-37\\" style=\\"color: rgb(255, 255, 255);\\"><svg class=\\"MuiSvgIcon-root-40\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path d=\\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\\"></path><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path></svg></div><input aria-invalid=\\"false\\" autocomplete=\\"off\\" class=\\"MuiInputBase-input-28 MuiInput-input-13 css-hodoyq MuiInputBase-inputAdornedStart-33\\" placeholder=\\"Search Packages\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiPaper-root-49 MuiPaper-elevation2-53 react-autosuggest__suggestions-container css-1aijpo3 e18292mt1\\" id=\\"react-autowhatever-1\\" role=\\"listbox\\"></div></div></div>"`;

0 commit comments

Comments
 (0)