fix: resolve dark mode contrast issues on legal pages
Description This PR fixes #7677
In dark mode, text on Code of Conduct and Terms of Service pages was invisible (dark text on dark background). On Privacy page, the data processing table was rendering in light mode regardless of user's theme preference. Issue resolved only after manually switching theme.
Root Cause
terms.style.jshad no color properties defined, so text became invisible in dark modeprivacy/index.js—SistentThemeProviderwas rendering with wrong initial theme beforeThemeManagerresolved correct theme from localStoragesub-processors/index.js—SistentThemeProviderwas not re-mounting on theme changecookie-notice/index.js- used the same table rendering pattern and was affected by the same theme initialization behavior.
Changes Made
terms.style.js: addedprops.theme.whiteToBlackcolor for all text elements to ensure proper contrast in dark and light modeprivacy/index.js: addeddidLoadflag to deferSistentThemeProviderrender until theme is fully resolved, preventing incorrect light mode flash on tablesub-processors/index.js: addedkey={isDark ? "dark" : "light"}anddidLoadflag toSistentThemeProviderto force re-mount on theme changecookie-notice/index.js: addeddidLoadflag andkeyprop toSistentThemeProvider(same table setup as privacy page)
Affected Pages
- Code of Conduct
- Terms of Service
- Privacy Policy
- Cookie Notice
- Sub-Processors
Notes for Reviewers No new dependencies added. Changes are scoped only to legal pages.
- [x] Yes, I signed my commits.
https://github.com/user-attachments/assets/efcdcca6-5491-4962-a636-70971ce7563a
Hey @Rajesh-Nagarajan-11, @banana-three-join, @KatalKavya96, @rishiraj38 👋 I closed the previous PR since it got cluttered with merge commits and opened a new clean PR with all the requested changes. Whenever you have some time, could you please take a look and let me know if anything else needs to be updated?
Preview deployment for PR #7789 removed.
This PR preview was automatically pruned because we keep only the 6 most recently updated previews on GitHub Pages to stay within deployment size limits.
If needed, push a new commit to this PR to generate a fresh preview.
@KatalKavya96 These pages were affected because they all share the same terms.style.js component. The dark mode contrast fix was made in this shared file, so it automatically applied to all legal pages using it.
Also, Privacy Policy, Cookie Notice, and Sub-Processors use the same dark mode setup (SistentThemeProvider + useStyledDarkMode), so they needed the same fix for consistent rendering.
Limiting the change to only Code of Conduct and Terms of Service would have left the same issue on the other legal pages.
@AnkitRewar11 Thank you for your contribution! Let's discuss this during the website call tomorrow at 5:30 PM IST | 7 AM CST Add it as an agenda item to the meeting minutes, if you would :slightly_smiling_face:
@rishiraj38 @Rajesh-Nagarajan-11 please take a look.
@AnkitRewar11 Thank you for your contribution! Let's discuss this during the website call tomorrow at 5:30 PM IST | 7 AM CST Add it as an agenda item to the meeting minutes, if you would :slightly_smiling_face:
createTheme is currently being called inside the component, so a new theme object is created on every render. Since the theme looks static, what are your thoughts on moving it outside the component so it’s created only once and avoids unnecessary re-creation on each render?
@Sbragul26 You're right bro. This change will prevent unnecessary work on each render and significantly improve performance. I've updated it. Thanks for the heads-up!
@AnkitRewar11 ,LGTM
@AnkitRewar11 LGTM
📝 Walkthrough
Walkthrough
Legal pages now initialize custom themes after mounting and remount providers when the color mode changes. Terms page text also uses the theme’s whiteToBlack color.
Changes
Legal theme rendering
| Layer / File(s) | Summary |
|---|---|
Client-side theme initialization src/sections/Company/Legal/cookie-notice/index.js, src/sections/Company/Legal/privacy/index.js, src/sections/Company/Legal/sub-processors/index.js |
Custom themes move to module scope. Each component renders its SistentThemeProvider after mount with a mode-based key. |
Terms page text styling src/sections/Company/Legal/terms.style.js |
The page header applies whiteToBlack to headings, paragraphs, and list items from h2 through h6. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Suggested labels: project/meshery
Suggested reviewers: rishiraj38
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly summarizes the main change: fixing dark-mode contrast issues on legal pages. |
| Linked Issues check | ✅ Passed | The changes address issue [#7677] by applying theme-aware contrast and initializing legal-page themes during navigation. |
| Out of Scope Changes check | ✅ Passed | All changes remain within the legal-page theme, text contrast, and dark-mode rendering objectives. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
- [ ] Create stacked PR
- [ ] Commit on current branch
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
ESLint install timed out. The project may have too many dependencies for the sandbox.
Comment @coderabbitai help to get the list of available commands.