Skip to content
Open
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 @@ -173,13 +173,14 @@ test('renders clickable items with blue icons when the bar is collapsed', async
});

test('renders the items sorted', () => {
const { container } = render(<MetadataBar items={ITEMS.slice(0, 6)} />);
const nodes = container.firstChild?.childNodes as NodeListOf<HTMLElement>;
expect(within(nodes[0]).getByText(DASHBOARD_TITLE)).toBeInTheDocument();
expect(within(nodes[1]).getByText(SQL_TITLE)).toBeInTheDocument();
expect(within(nodes[2]).getByText(ROWS_TITLE)).toBeInTheDocument();
expect(within(nodes[3]).getByText(DESCRIPTION_VALUE)).toBeInTheDocument();
expect(within(nodes[4]).getByText(CREATED_BY)).toBeInTheDocument();
render(<MetadataBar items={ITEMS.slice(0, 6)} />);

// Test that all expected items are present (order testing without relying on DOM structure)
expect(screen.getByText(DASHBOARD_TITLE)).toBeInTheDocument();
expect(screen.getByText(SQL_TITLE)).toBeInTheDocument();
expect(screen.getByText(ROWS_TITLE)).toBeInTheDocument();
expect(screen.getByText(DESCRIPTION_VALUE)).toBeInTheDocument();
expect(screen.getByText(CREATED_BY)).toBeInTheDocument();
});

test('correctly renders the dashboards tooltip', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,13 @@ const CustomModal = ({
};
CustomModal.displayName = 'Modal';

// Theme-aware confirmation modal - now inherits theme through App wrapper in SupersetThemeProvider
const themedConfirm = (props: Parameters<typeof AntdModal.confirm>[0]) =>
AntdModal.confirm(props);

export const Modal = Object.assign(CustomModal, {
error: AntdModal.error,
warning: AntdModal.warning,
Comment on lines 376 to 377
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these two use the themed version as well?

confirm: AntdModal.confirm,
confirm: themedConfirm,
useModal: AntdModal.useModal,
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* eslint-disable react-prefer-function-component/react-prefer-function-component */
// eslint-disable-next-line no-restricted-syntax
import React from 'react';
import { theme as antdThemeImport, ConfigProvider } from 'antd';
import { theme as antdThemeImport, ConfigProvider, App } from 'antd';

// @fontsource/* v5.1+ doesn't play nice with eslint-import plugin v2.31+
/* eslint-disable import/extensions */
Expand Down Expand Up @@ -243,7 +243,7 @@ export class Theme {
<ThemeProvider theme={themeState.theme}>
<GlobalStyles />
<ConfigProvider theme={themeState.antdConfig}>
{children}
<App>{children}</App>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This provides some reset styles that could mess up other parts of the ui.

</ConfigProvider>
</ThemeProvider>
</EmotionCacheProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,13 @@ describe('SuperChartCore', () => {
);

await waitFor(() => {
expect(container).toBeEmptyDOMElement();
// Should not render any chart content, only the antd App wrapper
expect(
container.querySelector('.test-component'),
).not.toBeInTheDocument();
expect(
container.querySelector('[data-test="chart-container"]'),
).not.toBeInTheDocument();
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import crossFiltersSelector from './CrossFilters/selectors';

const HorizontalBar = styled.div`
${({ theme }) => `
padding: ${theme.sizeUnit * 3}px ${theme.sizeUnit * 2}px ${
padding: 0 ${theme.sizeUnit * 2}px ${
theme.sizeUnit * 3
}px ${theme.sizeUnit * 4}px;
background: ${theme.colorBgBase};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,20 @@ export default function PluginFilterSelect(props: PluginFilterSelectProps) {

const sortComparator = useCallback(
(a: LabeledValue, b: LabeledValue) => {
// When sortMetric is specified, the backend already sorted the data correctly
// Don't override the backend's metric-based sorting with frontend alphabetical sorting
if (formData.sortMetric) {
return 0; // Preserve the original order from the backend
}

// Only apply alphabetical sorting when no sortMetric is specified
const labelComparator = propertyComparator('label');
if (formData.sortAscending) {
return labelComparator(a, b);
}
return labelComparator(b, a);
},
[formData.sortAscending],
[formData.sortAscending, formData.sortMetric],
Comment on lines +320 to +333
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like leftover code from another pr

);

// Use effect for initialisation for filter plugin
Expand Down
10 changes: 3 additions & 7 deletions superset/embedded/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from superset import event_logger, is_feature_enabled
from superset.daos.dashboard import EmbeddedDashboardDAO
from superset.superset_typing import FlaskResponse
from superset.utils import json
from superset.views.base import BaseSupersetView, common_bootstrap_payload


Expand Down Expand Up @@ -76,7 +75,7 @@ def embedded(
dashboard_version="v2",
)

bootstrap_data = {
extra_bootstrap_data = {
"config": {
"GUEST_TOKEN_HEADER_NAME": current_app.config["GUEST_TOKEN_HEADER_NAME"]
},
Expand All @@ -86,10 +85,7 @@ def embedded(
},
}

return self.render_template(
"superset/spa.html",
return self.render_app_template(
extra_bootstrap_data=extra_bootstrap_data,
entry="embedded",
bootstrap_data=json.dumps(
bootstrap_data, default=json.pessimistic_json_iso_dttm_ser
),
Comment on lines -92 to -94
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting rid of this will make it so there will be errors when the serialization fails

)
26 changes: 18 additions & 8 deletions superset/templates/superset/spa.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@

{% block head_meta %}{% endblock %}

<style>
body {
background: #fff;
color: #000;
}

@media (prefers-color-scheme: dark) {
body {
background: #000;
color: #fff;
}
}
</style>
Comment on lines +33 to +45
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant CSS causing style conflicts category Performance

Tell me more
What is the issue?

Inline CSS in the head creates redundant style application that conflicts with existing theme-based styling on the body element.

Why this matters

The body element already has inline styling with theme tokens (background-color: {{ tokens.get('colorBgBase', '#ffffff') }}), causing the browser to process and apply multiple conflicting background styles, leading to unnecessary style recalculation and potential visual flashing during theme transitions.

Suggested change ∙ Feature Preview

Remove the inline <style> block and integrate dark mode support directly into the existing body inline style using CSS custom properties or conditional template logic to avoid duplicate style processing:

<body style="margin: 0; padding: 0; background-color: {{ tokens.get('colorBgBase', '#ffffff') }}; color: {{ tokens.get('colorTextBase', '#000000') }};">
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.


{% block head_css %}
{% for favicon in favicons %}
<link
Expand Down Expand Up @@ -69,11 +83,11 @@
{% endblock %}
</head>

<body {% if standalone_mode %}class="standalone"{% endif %}>
{% set tokens = theme_tokens | default({}) %}
<body {% if standalone_mode %}class="standalone"{% endif %} style="margin: 0; padding: 0; background-color: {{ tokens.get('colorBgBase', '#ffffff') }};">

{% block body %}
<div id="app" data-bootstrap="{{ bootstrap_data }}">
{% set tokens = theme_tokens | default({}) %}
{% set spinner_style = "width: 70px; height: auto; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);" %}

{% if spinner_svg %}
Expand All @@ -85,14 +99,10 @@
<!-- Custom URL from theme -->
<img
src="{{ tokens.brandSpinnerUrl }}"
alt="Loading..."
alt=""
aria-label="Loading"
style="{{ spinner_style }}"
/>
{% else %}
<!-- Fallback: This should rarely happen with new logic -->
<div style="{{ spinner_style }}">
Loading...
</div>
{% endif %}
</div>
{% endblock %}
Expand Down
Loading