layer5 icon indicating copy to clipboard operation
layer5 copied to clipboard

fix: resolve dark mode contrast issues on legal pages

Open AnkitRewar11 opened this issue 5 months ago • 8 comments

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.js had no color properties defined, so text became invisible in dark mode
  • privacy/index.js — SistentThemeProvider was rendering with wrong initial theme before ThemeManager resolved correct theme from localStorage
  • sub-processors/index.js — SistentThemeProvider was not re-mounting on theme change
  • cookie-notice/index.js - used the same table rendering pattern and was affected by the same theme initialization behavior.

Changes Made

  • terms.style.js: added props.theme.whiteToBlack color for all text elements to ensure proper contrast in dark and light mode
  • privacy/index.js: added didLoad flag to defer SistentThemeProvider render until theme is fully resolved, preventing incorrect light mode flash on table
  • sub-processors/index.js: added key={isDark ? "dark" : "light"} and didLoad flag to SistentThemeProvider to force re-mount on theme change
  • cookie-notice/index.js: added didLoad flag and key prop to SistentThemeProvider (same table setup as privacy page)

Affected Pages

  1. Code of Conduct
  2. Terms of Service
  3. Privacy Policy
  4. Cookie Notice
  5. Sub-Processors

Notes for Reviewers No new dependencies added. Changes are scoped only to legal pages.

Signed commits

  • [x] Yes, I signed my commits.

https://github.com/user-attachments/assets/efcdcca6-5491-4962-a636-70971ce7563a

AnkitRewar11 avatar Jun 11 '26 19:06 AnkitRewar11

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?

AnkitRewar11 avatar Jun 11 '26 19:06 AnkitRewar11

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.

github-actions[bot] avatar Jun 11 '26 19:06 github-actions[bot]

@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 avatar Jun 12 '26 17:06 AnkitRewar11

@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:

Bhumikagarggg avatar Jun 14 '26 08:06 Bhumikagarggg

@rishiraj38 @Rajesh-Nagarajan-11 please take a look.

AnkitRewar11 avatar Jun 18 '26 07:06 AnkitRewar11

@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:

Bhumikagarggg avatar Jun 21 '26 18:06 Bhumikagarggg

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 avatar Jun 23 '26 15:06 Sbragul26

@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 avatar Jun 26 '26 06:06 AnkitRewar11

@AnkitRewar11 ,LGTM

AasthathecoderX avatar Jul 13 '26 06:07 AasthathecoderX

@AnkitRewar11 LGTM

dhruveshmishra avatar Jul 13 '26 08:07 dhruveshmishra

Review Change Stack

📝 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.

coderabbitai[bot] avatar Aug 01 '26 12:08 coderabbitai[bot]