You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/10/22 03:21:43 UTC
(superset) branch fix/double-scrollbar-narrow created (now 5c91acc9a73)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a change to branch fix/double-scrollbar-narrow
in repository https://gitbox.apache.org/repos/asf/superset.git
at 5c91acc9a73 fix: remove getPopupContainer causing double scrollbar (#35833)
This branch includes the following new commits:
new 5c91acc9a73 fix: remove getPopupContainer causing double scrollbar (#35833)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: fix: remove getPopupContainer causing double scrollbar (#35833)
Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch fix/double-scrollbar-narrow
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 5c91acc9a73f5fc4650ae2b1fd6476fe56e1432d
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Wed Oct 21 20:10:02 2026 -0700
fix: remove getPopupContainer causing double scrollbar (#35833)
Only the triggerNode.parentNode fallback (and the equivalent explicit
parentNode usage in ColorSchemeControl/ColorSchemeSelect/GroupByFilterCard)
produces the double scrollbar: an absolutely positioned popup laid out
inside an overflow:auto box grows a scrollbar of its own next to the
virtual list's. The .closest('.ant-modal-container') branch doesn't
exhibit this, so it stays, keeping the antd 6 modal-containment contract
(and antdDomContract.test.tsx) intact.
Co-Authored-By: BingEdward <bi...@gmail.com>
Co-Authored-By: Evan Rusackas <ev...@rusackas.com>
Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
---
.../src/components/Select/AsyncSelect.tsx | 2 +-
.../src/components/Select/Select.tsx | 2 +-
.../src/components/Select/types.ts | 4 ++
.../plugins/plugin-chart-word-cloud/package.json | 1 +
.../plugin/controls/ColorSchemeControl/index.tsx | 57 +++++++++++++---------
.../src/dashboard/components/ColorSchemeSelect.tsx | 55 +++++++++++++--------
.../FilterControls/GroupByFilterCard.test.tsx | 25 ++++++++++
.../FilterBar/FilterControls/GroupByFilterCard.tsx | 14 +++---
.../ColorSchemeControl/ColorSchemeControl.test.tsx | 27 ++++++++++
.../controls/ColorSchemeControl/index.tsx | 57 +++++++++++++---------
.../DateFilterControl/tests/CustomFrame.test.tsx | 14 +++---
11 files changed, 177 insertions(+), 81 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx
index 77417e525a4..08d143b25bd 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx
@@ -873,7 +873,7 @@ const AsyncSelect = forwardRef(
getPopupContainer ||
((triggerNode: HTMLElement) =>
(triggerNode?.closest('.ant-modal-container') as HTMLElement) ||
- (triggerNode.parentNode as HTMLElement))
+ document.body)
}
headerPosition={headerPosition}
labelInValue
diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
index d4ec1f7b9b4..d425668aaec 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx
@@ -1003,7 +1003,7 @@ const Select = forwardRef(
getPopupContainer ||
((triggerNode: HTMLElement) =>
(triggerNode?.closest('.ant-modal-container') as HTMLElement) ||
- (triggerNode.parentNode as HTMLElement))
+ document.body)
}
headerPosition={headerPosition}
labelInValue={labelInValue}
diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/types.ts b/superset-frontend/packages/superset-ui-core/src/components/Select/types.ts
index 8eee262ba21..15f66280df7 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Select/types.ts
+++ b/superset-frontend/packages/superset-ui-core/src/components/Select/types.ts
@@ -75,6 +75,10 @@ export type AntdExposedProps = Pick<
// lets a caller with long option labels stop the popup inheriting the
// trigger's width, which otherwise truncates every option
| 'popupMatchSelectWidth'
+ // let a caller style the popup, which portals to document.body and is
+ // therefore out of reach of the caller's scoped css/className
+ | 'styles'
+ | 'classNames'
>;
export type SelectOptionsType = Exclude<AntdProps['options'], undefined>;
diff --git a/superset-frontend/plugins/plugin-chart-word-cloud/package.json b/superset-frontend/plugins/plugin-chart-word-cloud/package.json
index d6901007363..4552ac845fd 100644
--- a/superset-frontend/plugins/plugin-chart-word-cloud/package.json
+++ b/superset-frontend/plugins/plugin-chart-word-cloud/package.json
@@ -39,6 +39,7 @@
},
"peerDependencies": {
"@apache-superset/core": "*",
+ "@emotion/react": "^11.4.1",
"@superset-ui/chart-controls": "*",
"@superset-ui/core": "*",
"@types/lodash": "^4.17.25",
diff --git a/superset-frontend/plugins/plugin-chart-word-cloud/src/plugin/controls/ColorSchemeControl/index.tsx b/superset-frontend/plugins/plugin-chart-word-cloud/src/plugin/controls/ColorSchemeControl/index.tsx
index 13083b1146c..effefbb8360 100644
--- a/superset-frontend/plugins/plugin-chart-word-cloud/src/plugin/controls/ColorSchemeControl/index.tsx
+++ b/superset-frontend/plugins/plugin-chart-word-cloud/src/plugin/controls/ColorSchemeControl/index.tsx
@@ -17,6 +17,7 @@
* under the License.
*/
import { useMemo, ReactNode } from 'react';
+import { ClassNames } from '@emotion/react';
import { t } from '@apache-superset/core/translation';
import {
@@ -304,28 +305,40 @@ const ColorSchemeControl = ({
/>
}
/>
- <Select
- css={css`
- width: 100%;
- & .ant-select-item.ant-select-item-group {
- padding-left: ${theme.sizeUnit}px;
- font-size: ${theme.fontSize}px;
- }
- & .ant-select-item-option-grouped {
- padding-left: ${theme.sizeUnit * 3}px;
- }
- `}
- aria-label={t('Select color scheme')}
- allowClear={clearable}
- disabled={hasDashboardScheme || hasSharedLabelsColor}
- onChange={handleOnChange}
- placeholder={t('Select scheme')}
- value={currentScheme}
- showSearch
- getPopupContainer={triggerNode => triggerNode.parentNode}
- options={options}
- optionFilterProps={['label', 'value', 'searchText']}
- />
+ <ClassNames>
+ {({ css: popupCss }) => (
+ <Select
+ css={css`
+ width: 100%;
+ `}
+ // the popup portals to document.body, out of the css prop's
+ // scope, so the grouped-option styles ride along on its root
+ classNames={{
+ popup: {
+ root: popupCss`
+ .ant-select-item.ant-select-item-group {
+ padding-left: ${theme.sizeUnit}px;
+ font-size: ${theme.fontSize}px;
+ }
+ .ant-select-item-option-grouped {
+ padding-left: ${theme.sizeUnit * 3}px;
+ }
+ `,
+ },
+ }}
+ aria-label={t('Select color scheme')}
+ allowClear={clearable}
+ disabled={hasDashboardScheme || hasSharedLabelsColor}
+ onChange={handleOnChange}
+ placeholder={t('Select scheme')}
+ value={currentScheme}
+ showSearch
+ getPopupContainer={() => document.body}
+ options={options}
+ optionFilterProps={['label', 'value', 'searchText']}
+ />
+ )}
+ </ClassNames>
</>
);
};
diff --git a/superset-frontend/src/dashboard/components/ColorSchemeSelect.tsx b/superset-frontend/src/dashboard/components/ColorSchemeSelect.tsx
index 548cad24f17..3cdcd6cce66 100644
--- a/superset-frontend/src/dashboard/components/ColorSchemeSelect.tsx
+++ b/superset-frontend/src/dashboard/components/ColorSchemeSelect.tsx
@@ -17,6 +17,7 @@
* under the License.
*/
import { ReactNode, useMemo } from 'react';
+import { ClassNames } from '@emotion/react';
import { t } from '@apache-superset/core/translation';
import {
ColorScheme,
@@ -172,27 +173,39 @@ const ColorSchemeSelect = ({
return (
<>
- <Select
- css={css`
- width: 100%;
- & .ant-select-item.ant-select-item-group {
- padding-left: ${theme.sizeUnit}px;
- font-size: ${theme.fontSize}px;
- }
- & .ant-select-item-option-grouped {
- padding-left: ${theme.sizeUnit * 3}px;
- }
- `}
- aria-label={t('Select color scheme')}
- allowClear={clearable}
- onChange={onChange}
- placeholder={t('Select scheme')}
- value={currentScheme}
- showSearch
- getPopupContainer={triggerNode => triggerNode.parentNode}
- options={options}
- optionFilterProps={['label', 'value', 'searchText']}
- />
+ <ClassNames>
+ {({ css: popupCss }) => (
+ <Select
+ css={css`
+ width: 100%;
+ `}
+ // the popup portals to document.body, out of the css prop's
+ // scope, so the grouped-option styles ride along on its root
+ classNames={{
+ popup: {
+ root: popupCss`
+ .ant-select-item.ant-select-item-group {
+ padding-left: ${theme.sizeUnit}px;
+ font-size: ${theme.fontSize}px;
+ }
+ .ant-select-item-option-grouped {
+ padding-left: ${theme.sizeUnit * 3}px;
+ }
+ `,
+ },
+ }}
+ aria-label={t('Select color scheme')}
+ allowClear={clearable}
+ onChange={onChange}
+ placeholder={t('Select scheme')}
+ value={currentScheme}
+ showSearch
+ getPopupContainer={() => document.body}
+ options={options}
+ optionFilterProps={['label', 'value', 'searchText']}
+ />
+ )}
+ </ClassNames>
{showWarning && hasCustomLabelsColor && (
<Tooltip title={CUSTOM_LABEL_ALERT}>
<Icons.WarningOutlined
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.test.tsx
index b2947d8fcda..b28d6e84b3b 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.test.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.test.tsx
@@ -532,3 +532,28 @@ test('shows no message while at least one allowed column remains', async () => {
expect(await screen.findByText('Country')).toBeInTheDocument();
expect(screen.queryByText(allowlistGoneMessage)).not.toBeInTheDocument();
});
+
+test('horizontal layout keeps the 200-400px popup width constraints', async () => {
+ // The popup portals to document.body, outside HorizontalFormItem's styled
+ // scope, so the width clamp must arrive as inline popup styles instead.
+ fetchMock.get('glob:*/api/v1/dataset/325', {
+ result: { table_name: 'Vehicle Sales', columns: [{ column_name: 'city' }] },
+ });
+
+ render(
+ <GroupByFilterCard
+ customizationItem={customization([{ datasetId: 325 }])}
+ orientation="horizontal"
+ />,
+ { useRedux: true, initialState },
+ );
+
+ await userEvent.click(await screen.findByRole('combobox'));
+ await waitFor(() => {
+ expect(document.querySelector('.ant-select-dropdown')).not.toBeNull();
+ });
+ expect(document.querySelector('.ant-select-dropdown')).toHaveStyle({
+ minWidth: '200px',
+ maxWidth: '400px',
+ });
+});
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.tsx
index a63c3b2ce24..4105ffd8bde 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.tsx
@@ -159,13 +159,14 @@ const HorizontalFormItem = styled(FormItem)`
.select-container {
width: 100%;
}
-
- .ant-select-dropdown {
- min-width: 200px !important;
- max-width: 400px !important;
- }
`;
+// The popup portals to document.body (out of HorizontalFormItem's styled
+// scope), so its width constraints ride along as inline popup styles.
+const HORIZONTAL_POPUP_STYLES = {
+ popup: { root: { minWidth: 200, maxWidth: 400 } },
+};
+
const ToolTipContainer = styled.div`
font-size: ${({ theme }) => theme.fontSize}px;
display: flex;
@@ -628,7 +629,8 @@ const GroupByFilterCard: FC<GroupByFilterCardProps> = ({
.includes(input.toLowerCase())
}
sortComparator={sortComparator}
- getPopupContainer={triggerNode => triggerNode.parentNode}
+ getPopupContainer={() => document.body}
+ styles={HORIZONTAL_POPUP_STYLES}
oneLine={isHorizontalLayout}
className="select-container"
loading={loading}
diff --git a/superset-frontend/src/explore/components/controls/ColorSchemeControl/ColorSchemeControl.test.tsx b/superset-frontend/src/explore/components/controls/ColorSchemeControl/ColorSchemeControl.test.tsx
index bd419d03191..5f89f37814c 100644
--- a/superset-frontend/src/explore/components/controls/ColorSchemeControl/ColorSchemeControl.test.tsx
+++ b/superset-frontend/src/explore/components/controls/ColorSchemeControl/ColorSchemeControl.test.tsx
@@ -151,6 +151,33 @@ test('displays color scheme options', async () => {
});
});
+test('grouped-option styles reach the popup portaled to document.body', async () => {
+ [...CategoricalD3, ...CategoricalModernSunset].forEach(scheme =>
+ getCategoricalSchemeRegistry().registerValue(scheme.id, scheme),
+ );
+ setup();
+ await userEvent.click(
+ screen.getByLabelText('Select color scheme', { selector: 'input' }),
+ );
+ await waitFor(() => {
+ expect(screen.getByText('Featured color palettes')).toBeInTheDocument();
+ });
+ const popup = document.querySelector('.ant-select-dropdown')!;
+ expect(popup.closest('body')).toBe(document.body);
+ // The popup lives outside the Select's css-prop scope, so the grouped
+ // styles are attached via an emotion class on the popup root instead.
+ const emotionClass = Array.from(popup.classList).find(cls =>
+ /^(superset|css)-(?!dev-only|var)/.test(cls),
+ );
+ expect(emotionClass).toBeDefined();
+ const styleText = Array.from(document.styleSheets)
+ .flatMap(sheet => Array.from(sheet.cssRules).map(rule => rule.cssText))
+ .join('\n');
+ expect(styleText).toContain(
+ `.${emotionClass} .ant-select-item-option-grouped`,
+ );
+});
+
test('Renders control with dashboard id and dashboard color scheme', () => {
setup({ dashboardId: 1, hasDashboardColorScheme: true });
expect(screen.getByText('Dashboard scheme')).toBeInTheDocument();
diff --git a/superset-frontend/src/explore/components/controls/ColorSchemeControl/index.tsx b/superset-frontend/src/explore/components/controls/ColorSchemeControl/index.tsx
index 99e08c21380..e1794e5ff1d 100644
--- a/superset-frontend/src/explore/components/controls/ColorSchemeControl/index.tsx
+++ b/superset-frontend/src/explore/components/controls/ColorSchemeControl/index.tsx
@@ -18,6 +18,7 @@
*/
import { useMemo, ReactNode } from 'react';
+import { ClassNames } from '@emotion/react';
import { t } from '@apache-superset/core/translation';
import {
ColorScheme,
@@ -303,28 +304,40 @@ const ColorSchemeControl = ({
/>
}
/>
- <Select
- css={css`
- width: 100%;
- & .ant-select-item.ant-select-item-group {
- padding-left: ${theme.sizeUnit}px;
- font-size: ${theme.fontSize}px;
- }
- & .ant-select-item-option-grouped {
- padding-left: ${theme.sizeUnit * 3}px;
- }
- `}
- aria-label={t('Select color scheme')}
- allowClear={clearable}
- disabled={hasDashboardScheme || hasSharedLabelsColor}
- onChange={handleOnChange}
- placeholder={t('Select scheme')}
- value={currentScheme}
- showSearch
- getPopupContainer={triggerNode => triggerNode.parentNode}
- options={options}
- optionFilterProps={['label', 'value', 'searchText']}
- />
+ <ClassNames>
+ {({ css: popupCss }) => (
+ <Select
+ css={css`
+ width: 100%;
+ `}
+ // the popup portals to document.body, out of the css prop's
+ // scope, so the grouped-option styles ride along on its root
+ classNames={{
+ popup: {
+ root: popupCss`
+ .ant-select-item.ant-select-item-group {
+ padding-left: ${theme.sizeUnit}px;
+ font-size: ${theme.fontSize}px;
+ }
+ .ant-select-item-option-grouped {
+ padding-left: ${theme.sizeUnit * 3}px;
+ }
+ `,
+ },
+ }}
+ aria-label={t('Select color scheme')}
+ allowClear={clearable}
+ disabled={hasDashboardScheme || hasSharedLabelsColor}
+ onChange={handleOnChange}
+ placeholder={t('Select scheme')}
+ value={currentScheme}
+ showSearch
+ getPopupContainer={() => document.body}
+ options={options}
+ optionFilterProps={['label', 'value', 'searchText']}
+ />
+ )}
+ </ClassNames>
</>
);
};
diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/tests/CustomFrame.test.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/tests/CustomFrame.test.tsx
index 765028f8d26..58a3cf99d9a 100644
--- a/superset-frontend/src/explore/components/controls/DateFilterControl/tests/CustomFrame.test.tsx
+++ b/superset-frontend/src/explore/components/controls/DateFilterControl/tests/CustomFrame.test.tsx
@@ -188,14 +188,12 @@ test('triggers onChange when the mode changes', async () => {
store,
});
await waitForElementToBeRemoved(() => screen.queryByLabelText('Loading'));
- await userEvent.click(screen.getByTitle('Midnight'));
- expect(await screen.findByTitle('Relative Date/Time')).toBeInTheDocument();
- await userEvent.click(screen.getByTitle('Relative Date/Time'));
- await userEvent.click(screen.getAllByTitle('Now')[1]);
- expect(
- await screen.findByText('Configure custom time range'),
- ).toBeInTheDocument();
- await userEvent.click(screen.getAllByTitle('Specific Date/Time')[1]);
+ await userEvent.click(screen.getByLabelText('Start (inclusive)'));
+ await userEvent.click(await screen.findByTitle('Relative Date/Time'));
+ await waitFor(() => expect(onChange).toHaveBeenCalledTimes(1));
+ await userEvent.click(screen.getByLabelText('End (exclusive)'));
+ const specificOptions = await screen.findAllByTitle('Specific Date/Time');
+ await userEvent.click(specificOptions[specificOptions.length - 1]);
await waitFor(() => expect(onChange).toHaveBeenCalledTimes(2));
});