Skip to content

Commit 7f216cb

Browse files
committed
do not show invalide for empty field
1 parent d343b51 commit 7f216cb

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

packages/iris-grid/src/sidebar/conditional-formatting/ConditionEditor.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,26 @@ function ConditionEditor(props: ConditionEditorProps): JSX.Element {
402402
// Column not selected
403403
return null;
404404
}
405+
406+
// Show invalid state only when there's a non-empty value that fails validation
407+
const hasInvalidValue =
408+
!isValid && conditionValue !== undefined && conditionValue !== '';
409+
405410
if (TableUtils.isNumberType(selectedColumnType)) {
411+
// For IS_BETWEEN, show invalid on each field only if that field has a value
412+
const showInvalid =
413+
selectedCondition === NumberCondition.IS_BETWEEN
414+
? !isValid &&
415+
((startValue !== undefined && startValue !== '') ||
416+
(endValue !== undefined && endValue !== ''))
417+
: hasInvalidValue;
418+
406419
return getNumberInputs(
407420
selectedCondition as NumberCondition,
408421
handleValueChange,
409422
handleStartValueChange,
410423
handleEndValueChange,
411-
!isValid,
424+
showInvalid,
412425
conditionValue,
413426
startValue,
414427
endValue
@@ -418,23 +431,23 @@ function ConditionEditor(props: ConditionEditorProps): JSX.Element {
418431
return getCharInputs(
419432
selectedCondition as CharCondition,
420433
handleValueChange,
421-
!isValid,
434+
hasInvalidValue,
422435
conditionValue
423436
);
424437
}
425438
if (TableUtils.isStringType(selectedColumnType)) {
426439
return getStringInputs(
427440
selectedCondition as StringCondition,
428441
handleValueChange,
429-
!isValid,
442+
hasInvalidValue,
430443
conditionValue
431444
);
432445
}
433446
if (TableUtils.isDateType(selectedColumnType)) {
434447
return getDateInputs(
435448
selectedCondition as DateCondition,
436449
handleValueChange,
437-
!isValid,
450+
hasInvalidValue,
438451
conditionValue
439452
);
440453
}

0 commit comments

Comments
 (0)