File tree Expand file tree Collapse file tree 3 files changed +35
-7
lines changed
packages/ui/src/elements/WhereBuilder/Condition Expand file tree Collapse file tree 3 files changed +35
-7
lines changed Original file line number Diff line number Diff line change @@ -76,12 +76,20 @@ export const Condition: React.FC<Props> = (props) => {
76
76
const debouncedValue = useDebounce ( internalQueryValue , 300 )
77
77
78
78
useEffect ( ( ) => {
79
- // This is to trigger changes when the debounced value changes
80
- if (
81
- ( fieldOption ?. value || typeof fieldOption ?. value === 'number' ) &&
82
- internalOperatorOption &&
83
- ! [ null , undefined ] . includes ( debouncedValue )
84
- ) {
79
+ if ( debouncedValue === undefined ) {
80
+ return
81
+ }
82
+
83
+ if ( debouncedValue === null ) {
84
+ removeCondition ( {
85
+ andIndex,
86
+ orIndex,
87
+ } )
88
+
89
+ return
90
+ }
91
+
92
+ if ( ( fieldOption ?. value || typeof fieldOption ?. value === 'number' ) && internalOperatorOption ) {
85
93
updateCondition ( {
86
94
andIndex,
87
95
fieldName : fieldOption . value ,
@@ -98,6 +106,7 @@ export const Condition: React.FC<Props> = (props) => {
98
106
orIndex ,
99
107
updateCondition ,
100
108
operator ,
109
+ removeCondition ,
101
110
] )
102
111
103
112
const booleanSelect =
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ import { reorderColumns } from '../../../helpers/e2e/reorderColumns.js'
44
44
import { reInitializeDB } from '../../../helpers/reInitializeDB.js'
45
45
import { POLL_TOPASS_TIMEOUT , TEST_TIMEOUT_LONG } from '../../../playwright.config.js'
46
46
import { addListFilter } from 'helpers/e2e/addListFilter.js'
47
+
47
48
const filename = fileURLToPath ( import . meta. url )
48
49
const currentFolder = path . dirname ( filename )
49
50
const dirname = path . resolve ( currentFolder , '../../' )
@@ -356,6 +357,24 @@ describe('List View', () => {
356
357
await expect ( page . locator ( '.condition__value input' ) ) . toHaveValue ( '' )
357
358
} )
358
359
360
+ test ( 'should remove condition from URL when value is cleared' , async ( ) => {
361
+ await page . goto ( postsUrl . list )
362
+
363
+ await addListFilter ( {
364
+ page,
365
+ fieldLabel : 'Relationship' ,
366
+ operatorLabel : 'equals' ,
367
+ value : 'post1' ,
368
+ } )
369
+
370
+ await page . waitForURL ( / & w h e r e / )
371
+
372
+ const valueInput = page . locator ( '.condition__value' )
373
+ const removeButton = valueInput . locator ( '.clear-indicator' ) . click ( )
374
+
375
+ await page . waitForURL ( / ^ (? ! .* & w h e r e ) / )
376
+ } )
377
+
359
378
test ( 'should accept where query from valid URL where parameter' , async ( ) => {
360
379
// delete all posts created by the seed
361
380
await deleteAllPosts ( )
Original file line number Diff line number Diff line change 31
31
}
32
32
],
33
33
"paths" : {
34
- "@payload-config" : [" ./test/fields /config.ts" ],
34
+ "@payload-config" : [" ./test/admin /config.ts" ],
35
35
"@payloadcms/live-preview" : [" ./packages/live-preview/src" ],
36
36
"@payloadcms/live-preview-react" : [" ./packages/live-preview-react/src/index.ts" ],
37
37
"@payloadcms/live-preview-vue" : [" ./packages/live-preview-vue/src/index.ts" ],
You can’t perform that action at this time.
0 commit comments