Skip to content
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

fix: Clean up custom css when dashboard unmounted #19342

Conversation

codemaster08240328
Copy link
Contributor

SUMMARY

This happened because the previous version didn't clear customCss when dashboard is unmounted.
So user could see injected css unless the browser was refreshed by force or some reason.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE:

[DEV] Superset - 23 March 2022 - Watch Video



AFTER:

[DEV] Superset - 23 March 2022 - Watch Video



TESTING INSTRUCTIONS

  • Create CSS template (e.g. body { background-color: pink; } )
  • Open any dashboard and enter edit mode
  • Click on 3 dots menu and click "edit CSS"
  • Load css template and close the "CSS" modal
  • Save changes and visit any page

ADDITIONAL INFORMATION

  • Dashboard CSS Injection Issue

() => () => {
// need to clean up custom css
// when dashboard unmounts
injectCustomCss('');
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at line 235, it seems like the function injectCustomCss was designed to handle the cleanup (or that was the intention).
I would recommend reviewing that function and finding out why is it not working.
The useEffect from above should be sufficient then.

@codecov
Copy link

codecov bot commented Mar 23, 2022

Codecov Report

Merging #19342 (ab22200) into master (a4c261d) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           master   #19342    +/-   ##
========================================
  Coverage   66.59%   66.59%            
========================================
  Files        1670     1676     +6     
  Lines       63888    64703   +815     
  Branches     6510     6519     +9     
========================================
+ Hits        42544    43088   +544     
- Misses      19655    19924   +269     
- Partials     1689     1691     +2     
Flag Coverage Δ
javascript 51.25% <ø> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rontend/src/dashboard/containers/DashboardPage.tsx 5.31% <ø> (+0.05%) ⬆️
superset/migrations/shared/utils.py 0.00% <0.00%> (-82.06%) ⬇️
superset/connectors/sqla/views.py 63.67% <0.00%> (-27.99%) ⬇️
superset/cli/test.py 83.72% <0.00%> (-10.22%) ⬇️
.../components/Header/HeaderActionsDropdown/index.jsx 67.79% <0.00%> (-3.64%) ⬇️
superset/connectors/sqla/utils.py 91.66% <0.00%> (-2.72%) ⬇️
superset/key_value/utils.py 91.66% <0.00%> (-2.46%) ⬇️
superset/views/core.py 75.87% <0.00%> (-1.12%) ⬇️
superset/key_value/commands/delete_expired.py 80.00% <0.00%> (-0.77%) ⬇️
...frontend/src/dashboard/components/Header/index.jsx 60.92% <0.00%> (-0.46%) ⬇️
... and 133 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4c261d...ab22200. Read the comment docs.

@rusackas rusackas merged commit a88fa89 into apache:master Apr 5, 2022
@rusackas
Copy link
Member

rusackas commented Apr 5, 2022

LGTM! Thanks!

sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Apr 6, 2022
* clean up custom css when dashboard unmounted

* resolve comment

(cherry picked from commit a88fa89)
@sadpandajoe
Copy link
Member

🏷️ preset:2022.13

philipher29 pushed a commit to ValtechMobility/superset that referenced this pull request Jun 9, 2022
* clean up custom css when dashboard unmounted

* resolve comment
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset:2022.13 Preset-Patch size/XS 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants