diff --git a/superset-frontend/src/explore/components/ControlRow.test.tsx b/superset-frontend/src/explore/components/ControlRow.test.tsx
index 0b57078676548..bbd911b3aeaf4 100644
--- a/superset-frontend/src/explore/components/ControlRow.test.tsx
+++ b/superset-frontend/src/explore/components/ControlRow.test.tsx
@@ -19,49 +19,73 @@
import React from 'react';
import { render, screen } from 'spec/helpers/testing-library';
import ControlSetRow from 'src/explore/components/ControlRow';
+import StashFormDataContainer from './StashFormDataContainer';
const MockControl = (props: {
children: React.ReactElement;
type?: string;
isVisible?: boolean;
}) =>
{props.children}
;
-describe('ControlSetRow', () => {
- it('renders a single row with one element', () => {
- render(My Control 1]} />);
- expect(screen.getAllByText('My Control 1').length).toBe(1);
- });
- it('renders a single row with two elements', () => {
- render(
- My Control 1, My Control 2
]} />,
- );
- expect(screen.getAllByText(/My Control/)).toHaveLength(2);
- });
+test('renders a single row with one element', () => {
+ render(My Control 1]} />);
+ expect(screen.getAllByText('My Control 1').length).toBe(1);
+});
+test('renders a single row with two elements', () => {
+ render(
+ My Control 1, My Control 2
]} />,
+ );
+ expect(screen.getAllByText(/My Control/)).toHaveLength(2);
+ expect(screen.getAllByText(/My Control/)[0]).toBeVisible();
+ expect(screen.getAllByText(/My Control/)[1]).toBeVisible();
+});
- it('renders a single row with one elements if is HiddenControl', () => {
- render(
- My Control 1,
-
- My Control 2
- ,
- ]}
- />,
- );
- expect(screen.getAllByText(/My Control/)).toHaveLength(2);
- });
+test('renders a single row with one elements if is HiddenControl', () => {
+ render(
+ My Control 1,
+
+ My Control 2
+ ,
+ ]}
+ />,
+ );
+ expect(screen.getAllByText(/My Control/)).toHaveLength(2);
+ expect(screen.getAllByText(/My Control/)[0]).toBeVisible();
+ expect(screen.getAllByText(/My Control/)[1]).not.toBeVisible();
+});
+
+test('renders a single row with one elements if is invisible', () => {
+ render(
+ My Control 1,
+
+ My Control 2
+ ,
+ ]}
+ />,
+ );
+ expect(screen.getAllByText(/My Control/)).toHaveLength(2);
+ expect(screen.getAllByText(/My Control/)[0]).toBeVisible();
+ expect(screen.getAllByText(/My Control/)[1]).not.toBeVisible();
+});
- it('renders a single row with one elements if is invisible', () => {
- render(
- My Control 1,
+test('renders a single row with one element wrapping with StashContainer if is invisible', () => {
+ render(
+ My Control 1,
+
My Control 2
- ,
- ]}
- />,
- );
- expect(screen.getAllByText(/My Control/)).toHaveLength(2);
- });
+
+ ,
+ ]}
+ />,
+ { useRedux: true },
+ );
+ expect(screen.getAllByText(/My Control/)).toHaveLength(2);
+ expect(screen.getAllByText(/My Control/)[0]).toBeVisible();
+ expect(screen.getAllByText(/My Control/)[1]).not.toBeVisible();
});
diff --git a/superset-frontend/src/explore/components/ControlRow.tsx b/superset-frontend/src/explore/components/ControlRow.tsx
index 5721b5de28937..291faa8115858 100644
--- a/superset-frontend/src/explore/components/ControlRow.tsx
+++ b/superset-frontend/src/explore/components/ControlRow.tsx
@@ -23,12 +23,13 @@ const NUM_COLUMNS = 12;
type Control = React.ReactElement | null;
export default function ControlRow({ controls }: { controls: Control[] }) {
- const isHiddenControl = useCallback(
- (control: Control) =>
- control?.props.type === 'HiddenControl' ||
- control?.props.isVisible === false,
- [],
- );
+ const isHiddenControl = useCallback((control: Control) => {
+ const props =
+ control && 'shouldStash' in control.props
+ ? control.props.children.props
+ : control?.props;
+ return props?.type === 'HiddenControl' || props?.isVisible === false;
+ }, []);
// Invisible control should not be counted
// in the columns number
const countableControls = controls.filter(
@@ -41,6 +42,7 @@ export default function ControlRow({ controls }: { controls: Control[] }) {
{controls.map((control, i) => (