Skip to content

fix(filters modal): layout cleanup, simplification, fixes #31448

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export const nativeFilters = {
silentLoading: '.loading inline-centered css-101mkpk',
filterConfigurationSections: {
sectionHeader: '.ant-collapse-header',
displayedSection: 'div[style="height: 100%; overflow-y: auto;"]',
displayedSection: dataTestLocator('filter-configuration-tab'),
collapseExpandButton: '.ant-collapse-arrow',
checkedCheckbox: '.ant-checkbox-wrapper-checked',
infoTooltip: '[aria-label="Show info tooltip"]',
Expand Down
7 changes: 0 additions & 7 deletions superset-frontend/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,6 @@ export const StyledModal = styled(BaseModal)<StyledModalProps>`
}
}

// styling for Tabs component
// Aaron note 20-11-19: this seems to be exclusively here for the Edit Database modal.
// TODO: remove this as it is a special case.
.ant-tabs-top {
margin-top: -${({ theme }) => theme.gridUnit * 4}px;
}

&.no-content-padding .ant-modal-body {
padding: 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,14 @@ interface Props {
removedFilters: Record<string, FilterRemoval>;
}

const Container = styled.div`
display: flex;
height: 100%;
`;

const ContentHolder = styled.div`
flex-grow: 3;
margin-left: ${({ theme }) => theme.gridUnit * -1 - 1};
`;

const TitlesContainer = styled.div`
const FiltersListPane = styled(FilterTitlePane)`
min-width: 300px;
max-width: 300px;
border-right: 1px solid ${({ theme }) => theme.colors.grayscale.light2};
`;

const FilterConfigurePane: FC<Props> = ({
Expand All @@ -64,23 +58,21 @@ const FilterConfigurePane: FC<Props> = ({
filters,
removedFilters,
}) => (
<Container>
<TitlesContainer>
<FilterTitlePane
currentFilterId={currentFilterId}
filters={filters}
removedFilters={removedFilters}
erroredFilters={erroredFilters}
getFilterTitle={getFilterTitle}
onChange={onChange}
onAdd={(type: NativeFilterType) => onAdd(type)}
onRearrange={onRearrange}
onRemove={(id: string) => onRemove(id)}
restoreFilter={restoreFilter}
/>
</TitlesContainer>
<>
<FiltersListPane
currentFilterId={currentFilterId}
filters={filters}
removedFilters={removedFilters}
erroredFilters={erroredFilters}
getFilterTitle={getFilterTitle}
onChange={onChange}
onAdd={(type: NativeFilterType) => onAdd(type)}
onRearrange={onRearrange}
onRemove={(id: string) => onRemove(id)}
restoreFilter={restoreFilter}
/>
<ContentHolder>{children}</ContentHolder>
</Container>
</>
);

export default FilterConfigurePane;
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const TabsContainer = styled.div`
flex-direction: column;
padding: ${({ theme }) => theme.gridUnit * 3}px;
padding-top: 2px;
border-right: 1px solid ${({ theme }) => theme.colors.grayscale.light2};
`;

const FilterTitlePane: FC<Props> = ({
Expand Down Expand Up @@ -79,25 +80,18 @@ const FilterTitlePane: FC<Props> = ({
};
return (
<TabsContainer>
<div
css={{
height: '100%',
overflowY: 'auto',
}}
>
<FilterTitleContainer
ref={filtersContainerRef}
filters={filters}
currentFilterId={currentFilterId}
removedFilters={removedFilters}
getFilterTitle={getFilterTitle}
erroredFilters={erroredFilters}
onChange={onChange}
onRemove={onRemove}
onRearrange={onRearrange}
restoreFilter={restoreFilter}
/>
</div>
<FilterTitleContainer
ref={filtersContainerRef}
filters={filters}
currentFilterId={currentFilterId}
removedFilters={removedFilters}
getFilterTitle={getFilterTitle}
erroredFilters={erroredFilters}
onChange={onChange}
onRemove={onRemove}
onRearrange={onRearrange}
restoreFilter={restoreFilter}
/>
<div
css={{
display: 'flex',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,14 @@ const StyledCollapse = styled(Collapse)`
`;

const StyledTabs = styled(Tabs)`
display: flex;
flex-direction: column;
height: 100%;
.ant-tabs-nav {
position: sticky;
top: 0;
background: ${({ theme }) => theme.colors.grayscale.light5};
z-index: 1;
}

.ant-tabs-nav-list {
padding: 0;
margin-bottom: 0;
}

.ant-form-item-label {
padding-bottom: 0;
.ant-tabs-content-holder {
overflow-y: scroll;
}
`;

Expand Down Expand Up @@ -826,6 +821,7 @@ const FiltersConfigForm = (
tab={FilterTabs.configuration.name}
key={FilterTabs.configuration.key}
forceRender
data-test="filter-configuration-tab"
>
<StyledContainer>
<StyledFormItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const MIN_WIDTH = 880;
const StyledModalWrapper = styled(StyledModal)<{ expanded: boolean }>`
min-width: ${MIN_WIDTH}px;
width: ${({ expanded }) => (expanded ? '100%' : MIN_WIDTH)} !important;
height: 100vh;

@media (max-width: ${MIN_WIDTH + MODAL_MARGIN * 2}px) {
width: 100% !important;
Expand All @@ -74,35 +75,24 @@ const StyledModalWrapper = styled(StyledModal)<{ expanded: boolean }>`

.ant-modal-body {
padding: 0px;
flex-basis: 100vh;
}

${({ expanded }) =>
expanded &&
css`
height: 100%;

.ant-modal-body {
flex: 1 1 auto;
}
.ant-modal-content {
height: 100%;
}
`}
`;

export const StyledModalBody = styled.div<{ expanded: boolean }>`
display: flex;
height: ${({ expanded }) => (expanded ? '100%' : '700px')};
flex-direction: row;
flex: 1;
.filters-list {
width: ${({ theme }) => theme.gridUnit * 50}px;
overflow: auto;
}
`;

export const StyledForm = styled(AntdForm)`
width: 100%;
height: 100%;
max-height: 100%;
overflow: hidden;
display: flex;
`;

export const StyledExpandButtonWrapper = styled.div`
Expand Down Expand Up @@ -646,11 +636,9 @@ function FiltersConfigModal({
const isActive = currentFilterId === id;
return (
<div
key={id}
style={{
height: '100%',
overflowY: 'auto',
display: isActive ? '' : 'none',
height: '100%',
}}
>
{isDivider ? (
Expand Down Expand Up @@ -741,28 +729,26 @@ function FiltersConfigModal({
}
>
<ErrorBoundary>
<StyledModalBody expanded={expanded}>
<StyledForm
form={form}
onValuesChange={handleValuesChange}
layout="vertical"
<StyledForm
form={form}
onValuesChange={handleValuesChange}
layout="vertical"
>
<FilterConfigurePane
erroredFilters={erroredFilters}
onRemove={handleRemoveItem}
onAdd={addFilter}
onChange={handleTabChange}
getFilterTitle={getFilterTitle}
currentFilterId={currentFilterId}
removedFilters={removedFilters}
restoreFilter={restoreFilter}
onRearrange={handleRearrange}
filters={orderedFilters}
>
<FilterConfigurePane
erroredFilters={erroredFilters}
onRemove={handleRemoveItem}
onAdd={addFilter}
onChange={handleTabChange}
getFilterTitle={getFilterTitle}
currentFilterId={currentFilterId}
removedFilters={removedFilters}
restoreFilter={restoreFilter}
onRearrange={handleRearrange}
filters={orderedFilters}
>
{formList}
</FilterConfigurePane>
</StyledForm>
</StyledModalBody>
{formList}
</FilterConfigurePane>
</StyledForm>
</ErrorBoundary>
</StyledModalWrapper>
);
Expand Down
Loading