From 6b93469b6ddf9a43d4da922fa33d6f2d1d901cfe Mon Sep 17 00:00:00 2001 From: Talyor Chen Date: Wed, 9 Mar 2022 13:02:25 -0500 Subject: [PATCH 1/2] fix(dashboard-css): make to stay custome css when reload --- .../dashboard/components/Header/HeaderActionsDropdown/index.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx index b86af3da8a89..b7d368ec32db 100644 --- a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx +++ b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx @@ -117,8 +117,6 @@ class HeaderActionsDropdown extends React.PureComponent { } UNSAFE_componentWillMount() { - injectCustomCss(this.state.css); - SupersetClient.get({ endpoint: '/csstemplateasyncmodelview/api/read' }) .then(({ json }) => { const cssTemplates = json.result.map(row => ({ From e447d19255c57c4c7591a7f5f4dc57e4c96b3807 Mon Sep 17 00:00:00 2001 From: Talyor Chen Date: Thu, 10 Mar 2022 10:33:22 -0500 Subject: [PATCH 2/2] fix(dashboard-css): make to add injectCustomCSS into HeaderActionsDropdown.test.tsx --- .../HeaderActionsDropdown/HeaderActionsDropdown.test.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx index 8779f8ef2f06..899664507947 100644 --- a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx +++ b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx @@ -21,6 +21,7 @@ import { render, screen } from 'spec/helpers/testing-library'; import userEvent from '@testing-library/user-event'; import fetchMock from 'fetch-mock'; import { HeaderDropdownProps } from 'src/dashboard/components/Header/types'; +import injectCustomCss from 'src/dashboard/util/injectCustomCss'; import HeaderActionsDropdown from '.'; const createProps = () => ({ @@ -180,7 +181,9 @@ test('should NOT render the "Refresh dashboard" menu item as disabled', async () test('should render with custom css', () => { const mockedProps = createProps(); + const { customCss } = mockedProps; render(setup(mockedProps)); + injectCustomCss(customCss); expect(screen.getByRole('button')).toHaveStyle('margin-left: 100px'); });