Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(explore): disable resize bar when the results area is collapsed #21366

Merged
merged 2 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion superset-frontend/src/explore/components/ExploreChartPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const Styles = styled.div`
}

.gutter.gutter-vertical {
display: ${({ showSplite }) => (showSplite ? 'block' : 'none')};
cursor: row-resize;
}

Expand Down Expand Up @@ -149,6 +150,9 @@ const ExploreChartPanel = ({
const [splitSizes, setSplitSizes] = useState(
getItem(LocalStorageKeys.chart_split_sizes, INITIAL_SIZES),
);
const [showSplite, setShowSplit] = useState(
getItem(LocalStorageKeys.is_datapanel_open, false),
);

const [showDatasetModal, setShowDatasetModal] = useState(false);

Expand Down Expand Up @@ -225,6 +229,7 @@ const ExploreChartPanel = ({
];
}
setSplitSizes(splitSizes);
setShowSplit(isOpen);
}, []);

const renderChart = useCallback(
Expand Down Expand Up @@ -411,7 +416,10 @@ const ExploreChartPanel = ({
}

return (
<Styles className="panel panel-default chart-container">
<Styles
className="panel panel-default chart-container"
showSplite={showSplite}
>
{vizType === 'filter_box' ? (
panelBody
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import userEvent from '@testing-library/user-event';
import { render, screen } from 'spec/helpers/testing-library';
import { getChartMetadataRegistry, ChartMetadata } from '@superset-ui/core';
import ChartContainer from 'src/explore/components/ExploreChartPanel';
import { setItem, LocalStorageKeys } from 'src/utils/localStorageHelpers';

const createProps = (overrides = {}) => ({
sliceName: 'Trend Line',
Expand Down Expand Up @@ -145,4 +146,16 @@ describe('ChartContainer', () => {
render(<ChartContainer {...props} />, { useRedux: true });
expect(screen.queryByText('Cached')).not.toBeInTheDocument();
});

it('hides gutter when collapsing data panel', async () => {
const props = createProps();
setItem(LocalStorageKeys.is_datapanel_open, true);
const { container } = render(<ChartContainer {...props} />, {
useRedux: true,
});
const gutter = container.querySelector('.gutter');
stephenLYZ marked this conversation as resolved.
Show resolved Hide resolved
expect(window.getComputedStyle(gutter).display).toBe('block');
userEvent.click(screen.getByLabelText('Collapse data panel'));
expect(window.getComputedStyle(gutter).display).toBe('none');
});
});