diff --git a/packages/lib/src/text-input/Suggestions.tsx b/packages/lib/src/text-input/Suggestions.tsx index 7355ada6f..9fbad145f 100644 --- a/packages/lib/src/text-input/Suggestions.tsx +++ b/packages/lib/src/text-input/Suggestions.tsx @@ -66,7 +66,12 @@ const Suggestions = ({ }, [visualFocusIndex]); return ( - + { + event.preventDefault(); + }} + style={styles} + > {isSearching ? ( {translatedLabels.textInput.searchingMessage} @@ -77,16 +82,7 @@ const Suggestions = ({ {translatedLabels.textInput.fetchingDataErrorMessage} ) : ( -
    { - event.preventDefault(); - }} - ref={listboxRef} - role="listbox" - style={{ margin: 0, padding: 0 }} - > +
      {suggestions.map((suggestion, index) => ( { expect(list).toBeTruthy(); expect(getAllByText("?").length).toBe(1); }); + + test("Autosuggest scrollbar behaviour", () => { + const onChange = jest.fn(); + const { getByRole, queryByRole } = render( + + ); + const input = getByRole("combobox"); + fireEvent.focus(input); + const list = getByRole("listbox"); + expect(list).toBeTruthy(); + + const suggestionsContainer = list.parentElement; + fireEvent.mouseDown(suggestionsContainer!); + expect(getByRole("listbox")).toBeTruthy(); + fireEvent.blur(input); + expect(queryByRole("listbox")).toBeFalsy(); + }); }); describe("TextInput component asynchronous autosuggest tests", () => {