Skip to content

Commit

Permalink
Use new immediate feature of headlessui v2
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliusroemer committed Jun 29, 2024
1 parent 1efe57a commit c522fe4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ export const ActiveDownloadFilters: FC<ActiveDownloadFiltersProps> = ({ lapisSea
let filterValues = Object.entries(lapisSearchParameters)
.filter((vals) => vals[1] !== undefined && vals[1] !== '')
.filter(([name, val]) => !(Object.keys(hiddenFieldValues).includes(name) && hiddenFieldValues[name] === val))
.map(([name, filterValue]) => ({ name, filterValue }));
.map(([name, filterValue]) => ({ name, filterValue: filterValue !== null ? filterValue : '' }));

filterValues = filterValues.filter(({ filterValue }) => filterValue.length > 0);

if (filterValues.length === 0) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('AutoCompleteField', () => {
setAFieldValue.mockClear();
});

it('renders input and shows all all options on empty input', async () => {
it('renders input and shows all options on empty input', async () => {
mockUseAggregated.mockReturnValue({
data: {
data: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ export const AutoCompleteField = ({
});

mutate({ fields: [field.name], ...otherFields });
if (buttonRef.current) {
buttonRef.current.click();
}
};

const options = useMemo(
Expand All @@ -85,7 +82,7 @@ export const AutoCompleteField = ({
);

return (
<Combobox value={fieldValue} onChange={(value) => setAFieldValue(field.name, value)}>
<Combobox immediate value={fieldValue} onChange={(value) => setAFieldValue(field.name, value)}>
<div className='relative'>
<ComboboxInput
className='w-full py-2 pl-3 text-sm leading-5
Expand All @@ -98,7 +95,7 @@ export const AutoCompleteField = ({
placeholder={field.label}
as={CustomInput}
/>
{((fieldValue !== '' && fieldValue !== undefined) || query !== '') && (
{((fieldValue !== '' && fieldValue !== undefined && fieldValue !== null) || query !== '') && (
<button
className='absolute inset-y-0 right-8 flex items-center pr-2 h-5 top-4 bg-white rounded-sm'
onClick={() => {
Expand Down

0 comments on commit c522fe4

Please sign in to comment.