Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/ui/src/elements/WhereBuilder/Condition/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ export const Condition: React.FC<Props> = (props) => {
valueOptions = reducedField.field.options
}

const updateValue = useEffectEvent(async (debouncedValue) => {
const updateValue = useEffectEvent(async (debouncedValue: Value) => {
if (operator) {
await updateCondition({
type: 'value',
andIndex,
field: reducedField,
operator,
orIndex,
value: debouncedValue === null ? '' : debouncedValue,
value: debouncedValue === null || debouncedValue === '' ? undefined : debouncedValue,
})
}
})
Expand Down
27 changes: 27 additions & 0 deletions test/admin/e2e/list-view/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,33 @@ describe('List View', () => {
await expect(valueInput).toHaveValue('Test')
})

test('should show all documents when equals filter value is cleared', async () => {
await page.goto(postsUrl.list)

await expect(page.locator(tableRowLocator)).toHaveCount(2)

const { whereBuilder } = await addListFilter({
page,
fieldLabel: 'Title',
operatorLabel: 'equals',
value: 'post1',
})

// Wait for filter to be applied
await page.waitForTimeout(500)

await expect(page.locator(tableRowLocator)).toHaveCount(1)

const valueInput = whereBuilder.locator('.condition__value >> input')
await valueInput.clear()

// Wait for debounce
await page.waitForTimeout(500)

// Should now show all 2 posts again (not 0 posts)
await expect(page.locator(tableRowLocator)).toHaveCount(2)
})

test('should still show second filter if two filters exist and first filter is removed', async () => {
await page.goto(postsUrl.list)

Expand Down
28 changes: 28 additions & 0 deletions test/admin/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export interface Config {
'list-view-select-api': ListViewSelectApi;
virtuals: Virtual;
'no-timestamps': NoTimestamp;
'payload-kv': PayloadKv;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
Expand Down Expand Up @@ -135,13 +136,15 @@ export interface Config {
'list-view-select-api': ListViewSelectApiSelect<false> | ListViewSelectApiSelect<true>;
virtuals: VirtualsSelect<false> | VirtualsSelect<true>;
'no-timestamps': NoTimestampsSelect<false> | NoTimestampsSelect<true>;
'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
};
db: {
defaultIDType: string;
};
fallbackLocale: ('false' | 'none' | 'null') | false | null | ('es' | 'en') | ('es' | 'en')[];
globals: {
'hidden-global': HiddenGlobal;
'not-in-view-global': NotInViewGlobal;
Expand Down Expand Up @@ -637,6 +640,23 @@ export interface NoTimestamp {
id: string;
title?: string | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-kv".
*/
export interface PayloadKv {
id: string;
key: string;
data:
| {
[k: string]: unknown;
}
| unknown[]
| string
| number
| boolean
| null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents".
Expand Down Expand Up @@ -1227,6 +1247,14 @@ export interface VirtualsSelect<T extends boolean = true> {
export interface NoTimestampsSelect<T extends boolean = true> {
title?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-kv_select".
*/
export interface PayloadKvSelect<T extends boolean = true> {
key?: T;
data?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents_select".
Expand Down
Loading