diff --git a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/AdhocFilterEditPopoverSimpleTabContent.test.tsx b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/AdhocFilterEditPopoverSimpleTabContent.test.tsx index a238ca38f284..c2b5231a90dc 100644 --- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/AdhocFilterEditPopoverSimpleTabContent.test.tsx +++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/AdhocFilterEditPopoverSimpleTabContent.test.tsx @@ -486,6 +486,70 @@ test('sets comparator to undefined when operator is IS_NULL or IS_NOT_NULL', () }); }); +test('hides the value input when operator is IS_NULL', () => { + setup({ + adhocFilter: new AdhocFilter({ + expressionType: ExpressionTypes.Simple, + subject: 'value', + operatorId: Operators.IsNull, + operator: OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.IsNull].operation, + comparator: undefined, + clause: Clauses.Where, + }), + }); + expect( + screen.queryByPlaceholderText('Filter value (case sensitive)'), + ).not.toBeInTheDocument(); +}); + +test('hides the value input when operator is IS_NOT_NULL', () => { + setup({ + adhocFilter: new AdhocFilter({ + expressionType: ExpressionTypes.Simple, + subject: 'value', + operatorId: Operators.IsNotNull, + operator: OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.IsNotNull].operation, + comparator: undefined, + clause: Clauses.Where, + }), + }); + expect( + screen.queryByPlaceholderText('Filter value (case sensitive)'), + ).not.toBeInTheDocument(); +}); + +test('hides the value input when operator is IS_TRUE', () => { + setup({ + adhocFilter: new AdhocFilter({ + expressionType: ExpressionTypes.Simple, + subject: 'value', + operatorId: Operators.IsTrue, + operator: OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.IsTrue].operation, + comparator: undefined, + clause: Clauses.Where, + }), + }); + expect( + screen.queryByPlaceholderText('Filter value (case sensitive)'), + ).not.toBeInTheDocument(); +}); + +test('hides the value input when operator is IS_FALSE', () => { + setup({ + adhocFilter: new AdhocFilter({ + expressionType: ExpressionTypes.Simple, + subject: 'value', + operatorId: Operators.IsFalse, + operator: OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.IsFalse].operation, + comparator: undefined, + clause: Clauses.Where, + }), + }); + expect( + screen.queryByPlaceholderText('Filter value (case sensitive)'), + ).not.toBeInTheDocument(); +}); + test('should not call API when column has no advanced data type', async () => { const props = getAdvancedDataTypeTestProps(); diff --git a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx index 64a590a01d8d..0ca989bd0bc5 100644 --- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx +++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx @@ -377,6 +377,14 @@ const AdhocFilterEditPopoverSimpleTabContent: FC = props => { const shouldFocusComparator = !!subjectSelectProps.value && !!operatorSelectProps.value; + const isUnaryOperator = + operatorId !== undefined && + DISABLE_INPUT_OPERATORS.includes(operatorId as Operators); + + const hasComparatorOptions = + (operatorId && MULTI_OPERATORS.has(operatorId as Operators)) || + suggestions.length > 0; + const comparatorSelectProps = { allowClear: true, allowNewOptions: true, @@ -389,9 +397,6 @@ const AdhocFilterEditPopoverSimpleTabContent: FC = props => { value: comparator as SelectValue, onChange: onComparatorChange, notFoundContent: t('Type a value here'), - disabled: - operatorId !== undefined && - DISABLE_INPUT_OPERATORS.includes(operatorId as Operators), placeholder: createSuggestionsPlaceholder(), }; @@ -555,49 +560,45 @@ const AdhocFilterEditPopoverSimpleTabContent: FC = props => { }))} {...operatorSelectProps} /> - {(operatorId && MULTI_OPERATORS.has(operatorId as Operators)) || - suggestions.length > 0 ? ( - - - - ) : ( - -
- + + + ) : ( + - - )} + > +
+ + + ))} ); return (