diff --git a/components/src/preact/textInput/TextChangedEvent.ts b/components/src/preact/textInput/TextInputChangedEvent.ts similarity index 76% rename from components/src/preact/textInput/TextChangedEvent.ts rename to components/src/preact/textInput/TextInputChangedEvent.ts index cc0b5a5b..70992124 100644 --- a/components/src/preact/textInput/TextChangedEvent.ts +++ b/components/src/preact/textInput/TextInputChangedEvent.ts @@ -1,6 +1,6 @@ type LapisTextFilter = Record; -export class TextChangedEvent extends CustomEvent { +export class TextInputChangedEvent extends CustomEvent { constructor(detail: LapisTextFilter) { super('gs-text-input-changed', { detail, diff --git a/components/src/preact/textInput/text-input.stories.tsx b/components/src/preact/textInput/text-input.stories.tsx index 1e5b48e4..5fb229d4 100644 --- a/components/src/preact/textInput/text-input.stories.tsx +++ b/components/src/preact/textInput/text-input.stories.tsx @@ -104,7 +104,7 @@ export const WithInitialValue: StoryObj = { await expect(changedListenerMock).toHaveBeenCalledWith( expect.objectContaining({ detail: { - host: null, + host: undefined, }, }), ); diff --git a/components/src/preact/textInput/text-input.tsx b/components/src/preact/textInput/text-input.tsx index 5acb44cf..adde6c49 100644 --- a/components/src/preact/textInput/text-input.tsx +++ b/components/src/preact/textInput/text-input.tsx @@ -5,7 +5,7 @@ import z from 'zod'; import { fetchAutocompleteList } from './fetchAutocompleteList'; import { LapisUrlContext } from '../LapisUrlContext'; -import { TextChangedEvent } from './TextChangedEvent'; +import { TextInputChangedEvent } from './TextInputChangedEvent'; import { ErrorBoundary } from '../components/error-boundary'; import { LoadingDisplay } from '../components/loading-display'; import { NoDataDisplay } from '../components/no-data-display'; @@ -94,7 +94,6 @@ const TextSelector = ({ return true; } return ( - item?.toLowerCase().includes(inputValue?.toLowerCase() || '') || item?.toLowerCase().includes(inputValue?.toLowerCase() || '') ); } @@ -117,7 +116,7 @@ const TextSelector = ({ }, onSelectedItemChange({ selectedItem }) { if (selectedItem !== null) { - divRef.current?.dispatchEvent(new TextChangedEvent({ [lapisField]: selectedItem })); + divRef.current?.dispatchEvent(new TextInputChangedEvent({ [lapisField]: selectedItem })); } }, items, @@ -130,7 +129,7 @@ const TextSelector = ({ const onInputBlur = () => { if (inputValue === '') { - divRef.current?.dispatchEvent(new TextChangedEvent({ [lapisField]: null })); + divRef.current?.dispatchEvent(new TextInputChangedEvent({ [lapisField]: undefined })); selectItem(null); } else if (inputValue !== selectedItem) { setInputValue(selectedItem || ''); @@ -138,7 +137,7 @@ const TextSelector = ({ }; const clearInput = () => { - divRef.current?.dispatchEvent(new TextChangedEvent({ [lapisField]: null })); + divRef.current?.dispatchEvent(new TextInputChangedEvent({ [lapisField]: undefined })); selectItem(null); }; diff --git a/components/src/web-components/input/gs-text-input.stories.ts b/components/src/web-components/input/gs-text-input.stories.ts index 2f957b92..121c1381 100644 --- a/components/src/web-components/input/gs-text-input.stories.ts +++ b/components/src/web-components/input/gs-text-input.stories.ts @@ -123,7 +123,7 @@ export const FiresEventNoValidInput: StoryObj> = { await userEvent.type(inputField(), '{backspace>9/}'); await inputField().blur(); await expect(listenerMock.mock.calls.at(-1)![0].detail).toStrictEqual({ - host: null, + host: undefined, }); }); },