Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7a9f687
Test fork commit
nelsondrew Apr 9, 2025
008fc01
Exclude filter values basic functionality
amaannawab923 Apr 9, 2025
937ef73
Styling for horizontal
amaannawab923 Apr 9, 2025
b6d9fa1
correction
amaannawab923 Apr 9, 2025
504273e
Fixed select widths
amaannawab923 Apr 9, 2025
7506e86
Test cases for the exclude filter checkbox
amaannawab923 Apr 9, 2025
1a68398
Checkbox styling
amaannawab923 Apr 9, 2025
cda90ab
Null check
amaannawab923 Apr 9, 2025
f3ae5ba
Removing unused variable
amaannawab923 Apr 9, 2025
aaa34e9
Updating immer reducer with value of excludeFilter Values
amaannawab923 Apr 9, 2025
75e543c
Running under use effect
amaannawab923 Apr 9, 2025
35e70a4
updating item widths so that uselayout effect runs
amaannawab923 Apr 10, 2025
063e4c4
linting fixes and type fixes
amaannawab923 Apr 10, 2025
8b5a085
Localisation
amaannawab923 Apr 10, 2025
dc5acc9
use Redux
amaannawab923 Apr 10, 2025
924d0f4
Unit tests correction
amaannawab923 Apr 10, 2025
ce494fe
pre commit
amaannawab923 Apr 11, 2025
7856c60
Using inverse selection
amaannawab923 Apr 14, 2025
f1568cc
Update test for new dropdown
amaannawab923 Apr 14, 2025
68eba89
map
amaannawab923 Apr 14, 2025
6293893
naming
amaannawab923 Apr 14, 2025
76372a9
Revert unncessary changes
amaannawab923 Apr 14, 2025
887ee1c
Select correction
amaannawab923 Apr 14, 2025
5113d49
Inverse selection condition
amaannawab923 Apr 15, 2025
9d55d04
naming
amaannawab923 Apr 15, 2025
a8caa4c
Merge branch 'master' of https://github.com/apache/superset into task…
amaannawab923 Apr 15, 2025
ca25451
Comments resolution
amaannawab923 Apr 15, 2025
3bd87a5
Used space
amaannawab923 Apr 16, 2025
2f8ca5f
Cypress fix
amaannawab923 Apr 16, 2025
d779c6e
Bug fix
amaannawab923 Apr 29, 2025
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
36 changes: 36 additions & 0 deletions superset-frontend/src/components/DropdownContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,42 @@ const DropdownContainer = forwardRef(
[items, overflowingIndex],
);

useEffect(() => {
const container = current?.children.item(0);
if (!container) return;

const childrenArray = Array.from(container.children);

const resizeObserver = new ResizeObserver(() => {
recalculateItemWidths();
});

childrenArray.map(child => resizeObserver.observe(child));

// eslint-disable-next-line consistent-return
return () => {
childrenArray.map(child => resizeObserver.unobserve(child));
resizeObserver.disconnect();
};
}, [items.length]);

// callback to update item widths so that the useLayoutEffect runs whenever
// width of any of the child changes
const recalculateItemWidths = () => {
const container = current?.children.item(0);
if (container) {
const { children } = container;
const childrenArray = Array.from(children);

const currentWidths = childrenArray.map(
child => child.getBoundingClientRect().width,
);

// Update state with new widths
setItemsWidth(currentWidths);
}
};

useLayoutEffect(() => {
if (popoverVisible) {
return;
Expand Down
4 changes: 3 additions & 1 deletion superset-frontend/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import { customTagRender } from './CustomTag';
const Select = forwardRef(
(
{
className,
allowClear,
allowNewOptions = false,
allowSelectAll = true,
Expand Down Expand Up @@ -121,6 +122,7 @@ const Select = forwardRef(
getPopupContainer,
oneLine,
maxTagCount: propsMaxTagCount,

...props
}: SelectProps,
ref: RefObject<HTMLInputElement>,
Expand Down Expand Up @@ -604,7 +606,7 @@ const Select = forwardRef(
};

return (
<StyledContainer headerPosition={headerPosition}>
<StyledContainer className={className} headerPosition={headerPosition}>
{header && (
<StyledHeader headerPosition={headerPosition}>{header}</StyledHeader>
)}
Expand Down
4 changes: 4 additions & 0 deletions superset-frontend/src/components/Select/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export type AntdExposedProps = Pick<
export type SelectOptionsType = Exclude<AntdProps['options'], undefined>;

export interface BaseSelectProps extends AntdExposedProps {
/**
* Optional CSS class name to apply to the select container
*/
className?: string;
/**
* It enables the user to create new options.
* Can be used with standard or async select types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ const HorizontalOverflowFilterControlContainer = styled(
}
`;

const VerticalFormItem = styled(StyledFormItem)`
const VerticalFormItem = styled(StyledFormItem)<{
inverseSelection: boolean;
}>`
.ant-form-item-label {
overflow: visible;
label.ant-form-item-required:not(.ant-form-item-required-mark-optional) {
Expand All @@ -118,9 +120,19 @@ const VerticalFormItem = styled(StyledFormItem)`
}
}
}

.select-container {
${({ inverseSelection }) =>
inverseSelection &&
`
width: 140px;
`}
}
`;

const HorizontalFormItem = styled(StyledFormItem)`
const HorizontalFormItem = styled(StyledFormItem)<{
inverseSelection: boolean;
}>`
&& {
margin-bottom: 0;
align-items: center;
Expand All @@ -142,7 +154,15 @@ const HorizontalFormItem = styled(StyledFormItem)`
}

.ant-form-item-control {
width: ${({ theme }) => theme.gridUnit * 41}px;
width: ${({ inverseSelection }) => (inverseSelection ? 252 : 164)}px;
}

.select-container {
${({ inverseSelection, theme }) =>
inverseSelection &&
`
width: 164px;
`}
}
`;

Expand All @@ -151,31 +171,41 @@ const HorizontalOverflowFormItem = VerticalFormItem;
const useFilterControlDisplay = (
orientation: FilterBarOrientation,
overflow: boolean,
inverseSelection: boolean,
) =>
useMemo(() => {
if (orientation === FilterBarOrientation.Horizontal) {
if (overflow) {
return {
FilterControlContainer: HorizontalOverflowFilterControlContainer,
FormItem: HorizontalOverflowFormItem,
FormItem: (props: any) => (
<HorizontalOverflowFormItem
{...props}
inverseSelection={inverseSelection}
/>
),
FilterControlTitleBox: HorizontalOverflowFilterControlTitleBox,
FilterControlTitle: HorizontalOverflowFilterControlTitle,
};
}
return {
FilterControlContainer: HorizontalFilterControlContainer,
FormItem: HorizontalFormItem,
FormItem: (props: any) => (
<HorizontalFormItem {...props} inverseSelection={inverseSelection} />
),
FilterControlTitleBox: HorizontalFilterControlTitleBox,
FilterControlTitle: HorizontalFilterControlTitle,
};
}
return {
FilterControlContainer: VerticalFilterControlContainer,
FormItem: VerticalFormItem,
FormItem: (props: any) => (
<VerticalFormItem {...props} inverseSelection={inverseSelection} />
),
FilterControlTitleBox: VerticalFilterControlTitleBox,
FilterControlTitle: VerticalFilterControlTitle,
};
}, [orientation, overflow]);
}, [orientation, overflow, inverseSelection]);

const ToolTipContainer = styled.div`
font-size: ${({ theme }) => theme.typography.sizes.m}px;
Expand Down Expand Up @@ -243,13 +273,14 @@ const FilterControl = ({
checkIsMissingRequiredValue(filter, filter.dataMask?.filterState);
const validateStatus = isMissingRequiredValue ? 'error' : undefined;
const isRequired = !!filter.controlValues?.enableEmptyFilter;
const inverseSelection = !!filter.controlValues?.inverseSelection;

const {
FilterControlContainer,
FormItem,
FilterControlTitleBox,
FilterControlTitle,
} = useFilterControlDisplay(orientation, overflow);
} = useFilterControlDisplay(orientation, overflow, inverseSelection);

const label = useMemo(
() => (
Expand Down
Loading