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(pivot-table): use scoped styles instead of global styles #1681

Merged

Conversation

HendrikThePendric
Copy link
Contributor

@HendrikThePendric HendrikThePendric commented Jun 13, 2024

Implements DHIS2-14028


Key features

  1. PivotTable now uses scoped styles which will not bleed out of the component

Description

The styles were probably originally declared using css.global because they should in fact affect nested components, and this doesn't happen normally because each component has its own CSS scope. But by making the entire style block global, plus using a generic CSS selector like table, the risk of these styles affecting other parts of the page becomes very significant.

What we need is "global" styles that impact sub-components but do not bleed out to sibling and parent components. In @dhis2/ui we have had to deal with this type of situation a lot and the most convenient pattern we established is the one I've applied here:

  • The styles themselves are scoped (i.e. using styled-jsx's css and not css.global)
  • Each selector starts with a scoped one that targets the container component element. NB: this is a div that is rendered by the PivotTableContainer component which imports these styles.
  • Each selector is then followed by a global selector which means it does affect sub-components too

Test instructions

This fix can actually be verified without installing this analytics bundle into DV. You can just use the storybook to test things out.


Screenshots

Before
Screenshot 2024-06-13 at 13 44 01

After
Screenshot 2024-06-13 at 13 44 42

@HendrikThePendric HendrikThePendric requested review from edoardo and martinkrulltott and removed request for edoardo June 13, 2024 12:02
@HendrikThePendric HendrikThePendric self-assigned this Jun 13, 2024
@HendrikThePendric HendrikThePendric removed the request for review from martinkrulltott June 13, 2024 12:03
@HendrikThePendric HendrikThePendric changed the title fix: use scoped styles instead of global styles pivot table fix(pivot-table): use scoped styles instead of global styles Jun 19, 2024
@HendrikThePendric HendrikThePendric merged commit 44b753a into master Jun 20, 2024
4 checks passed
@HendrikThePendric HendrikThePendric deleted the DHIS2-14028-remove-global-styles-from-pivot-table branch June 20, 2024 10:51
dhis2-bot added a commit that referenced this pull request Jun 20, 2024
## [26.7.4](v26.7.3...v26.7.4) (2024-06-20)

### Bug Fixes

* **pivot-table:** use a scoped base selector and global sub selectors ([#1681](#1681)) ([44b753a](44b753a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants