Skip to content

Commit e310d5c

Browse files
committed
fix: fix operation transitions values
- Fix bug when change from IS_SET or IS_NOT_SET to Modulo, it was breaking the page
1 parent f76b9fc commit e310d5c

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

frontend/common/types/responses.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export type Operator = {
3434
hideValue?: boolean
3535
warning?: string
3636
valuePlaceholder?: string
37+
append?: string
38+
type?: string
3739
}
3840
export type ChangeRequestSummary = {
3941
id: number

frontend/web/components/segments/Rule/Rule.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,26 @@ const Rule: React.FC<RuleProps> = ({
7676
operator: operatorValue?.split(':')[0],
7777
}
7878

79-
// Clear value when changing to or from IN operator
79+
// Handle append changes first
80+
if (prevOperator?.append !== newOperator?.append) {
81+
const conditionValue = typeof condition?.value === 'boolean' ? String(condition.value) : condition?.value
82+
const cleanValue = splitIfValue(conditionValue, prevOperator?.append || '')[0]
83+
updates.value = cleanValue + (newOperator?.append || '')
84+
}
85+
86+
// Clear value when changing to or from IN operator (after append handling)
8087
const isChangingToIn = operatorValue === 'IN'
8188
const isChangingFromIn = condition?.operator === 'IN'
8289
if (isChangingToIn || isChangingFromIn) {
8390
updates.value = ''
8491
}
8592

93+
// Set null for hideValue operators (takes precedence over everything)
8694
if (newOperator?.hideValue) {
8795
updates.value = null
88-
}
89-
90-
if (prevOperator?.append !== newOperator?.append) {
91-
const cleanValue = splitIfValue(condition?.value, prevOperator?.append)[0]
92-
updates.value = cleanValue + (newOperator?.append || '')
96+
} else if (prevOperator?.hideValue && !updates.hasOwnProperty('value')) {
97+
// When changing FROM a hideValue operator, initialize value to empty string
98+
updates.value = ''
9399
}
94100

95101
if (shouldAutoSetIdentityKey(operatorValue, condition.property)) {

0 commit comments

Comments
 (0)