Compare commits

...

3 Commits

Author SHA1 Message Date
shamoon
8edbc70dbc Oops, it should be dark 2026-04-18 16:02:09 -07:00
shamoon
862e8e2292 Fix: added date check visibility (#12600) 2026-04-18 05:14:31 -07:00
Gaëtan GOUZI
ae2b780509 Fix: prevent intermediate change event when CustomFieldQueryAtom operator changes type (#12597)
* fix: prevent intermediate change event when CustomFieldQueryAtom operator changes type

* Add regression test

---------

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
2026-04-17 23:23:48 +00:00
3 changed files with 22 additions and 7 deletions

View File

@@ -86,7 +86,7 @@
<div class="selected-icon"> <div class="selected-icon">
@if (addedRelativeDate) { @if (addedRelativeDate) {
<a class="text-light focus-variants" href="javascript:void(0)" (click)="clearAddedRelativeDate()"> <a class="text-light focus-variants" href="javascript:void(0)" (click)="clearAddedRelativeDate()">
<i-bs width="1em" height="1em" name="check" class="variant-unfocused"></i-bs> <i-bs width="1em" height="1em" name="check" class="variant-unfocused text-dark"></i-bs>
<i-bs width="1em" height="1em" name="x" class="variant-focused text-primary"></i-bs> <i-bs width="1em" height="1em" name="x" class="variant-focused text-primary"></i-bs>
</a> </a>
} }

View File

@@ -142,6 +142,21 @@ describe('CustomFieldQueryAtom', () => {
atom.value = [1, 3] atom.value = [1, 3]
expect(changeSpy).toHaveBeenCalledTimes(1) expect(changeSpy).toHaveBeenCalledTimes(1)
}) })
it('should emit one changed event when operator change coerces value', () => {
const atom = new CustomFieldQueryAtom([
1,
CustomFieldQueryOperator.In,
[1, 2],
])
const changeSpy = jest.fn()
atom.changed.subscribe(changeSpy)
atom.operator = CustomFieldQueryOperator.Exact
expect(changeSpy).toHaveBeenCalledTimes(1)
expect(atom.serialize()).toEqual([1, CustomFieldQueryOperator.Exact, ''])
})
}) })
describe('CustomFieldQueryExpression', () => { describe('CustomFieldQueryExpression', () => {

View File

@@ -70,29 +70,29 @@ export class CustomFieldQueryAtom extends CustomFieldQueryElement {
const newTypes: string[] = const newTypes: string[] =
CUSTOM_FIELD_QUERY_VALUE_TYPES_BY_OPERATOR[operator]?.split('|') CUSTOM_FIELD_QUERY_VALUE_TYPES_BY_OPERATOR[operator]?.split('|')
if (!newTypes) { if (!newTypes) {
this.value = null this._value = null
} else { } else {
if (!newTypes.includes(typeof this.value)) { if (!newTypes.includes(typeof this.value)) {
switch (newTypes[0]) { switch (newTypes[0]) {
case 'string': case 'string':
this.value = '' this._value = ''
break break
case 'boolean': case 'boolean':
this.value = 'true' this._value = 'true'
break break
case 'array': case 'array':
this.value = [] this._value = []
break break
case 'number': case 'number':
const num = parseFloat(this.value as string) const num = parseFloat(this.value as string)
this.value = isNaN(num) ? null : num.toString() this._value = isNaN(num) ? null : num.toString()
break break
} }
} else if ( } else if (
['true', 'false'].includes(this.value as string) && ['true', 'false'].includes(this.value as string) &&
newTypes.includes('string') newTypes.includes('string')
) { ) {
this.value = '' this._value = ''
} }
} }
super.operator = operator super.operator = operator