Skip to content

fix(theme):refactor theme selectors to support both html and body#2357

Open
lakshmi-priya-b wants to merge 7 commits intomainfrom
fix-3836/add-selector-for-html-element
Open

fix(theme):refactor theme selectors to support both html and body#2357
lakshmi-priya-b wants to merge 7 commits intomainfrom
fix-3836/add-selector-for-html-element

Conversation

@lakshmi-priya-b
Copy link
Collaborator

@lakshmi-priya-b lakshmi-priya-b commented Jan 23, 2026

💡 What is the current behavior?

  • When we try to toggle theme using 'enableToggleTheme' property in menu-component it is not working.
  • 'enableToggleTheme' is internally calling 'themeswitcher'.
  • Themeswitcher was modified to always target html element but selectors was still supporting only the body elements.

GitHub Issue Number: #2326

🆕 What is the new behavior?

  • When we try to toggle theme using 'enableToggleTheme' property in menu-component it is working.
  • Added selectors for html element as well.

🏁 Checklist

A pull request can only be merged if all of these conditions are met (where applicable):

  • 🦮 Accessibility (a11y) features were implemented
  • 🗺️ Internationalization (i18n) - no hard coded strings
  • 📲 Responsiveness - components handle viewport changes and content overflow gracefully
  • 📕 Add or update a Storybook story
  • 📄 Documentation was reviewed/updated siemens/ix-docs
  • 🧪 Unit tests were added/updated and pass (pnpm test)
  • 📸 Visual regression tests were added/updated and pass (Guide)
  • 🧐 Static code analysis passes (pnpm lint)
  • 🏗️ Successful compilation (pnpm build, changes pushed)

👨‍💻 Help & support

@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

⚠️ No Changeset found

Latest commit: 6f0db4f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lakshmi-priya-b, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical theming inconsistency where the themeswitcher component was designed to apply themes by modifying the html element, but the existing SCSS theme selectors were only configured to target the body element. The changes refactor these selectors to explicitly include both html and body elements for theme application, thereby enabling the enableToggleTheme functionality to work correctly across the application.

Highlights

  • Theme Selector Refactoring: Modified SCSS theme selectors in theme.scss to correctly apply theme variables to both html and body elements. This resolves an inconsistency where the themeswitcher targeted html while selectors only supported body.
  • Enable Toggle Theme Fix: Ensured the enableToggleTheme property in the menu-component now functions as expected by extending theme application to the html element, allowing for proper theme toggling.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the theme selectors to support applying themes to both the html and body elements, fixing an issue where theme toggling was not working correctly. The changes in packages/core/scss/theme/classic/theme.scss correctly add selectors for the html element. The fix is appropriate and addresses the problem described. I've included a couple of suggestions to improve the SCSS by using the :is() pseudo-class, which will make the selectors more concise and maintainable.

@lakshmi-priya-b
Copy link
Collaborator Author

Updated CSS class-based theme deprecation from v4.0.0 to v5.0.0 in the ix-docs.
PR-link : siemens/ix-docs#176

@lakshmi-priya-b lakshmi-priya-b marked this pull request as ready for review January 28, 2026 09:24
Copy link
Collaborator

Choose a reason for hiding this comment

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

Refactoring the selector to target the HTML element will introduce other problems. Instead fix theme switcher itself.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the theme switcher to use data attributes (data-ix-theme, data-ix-color-schema) on the <html> element for theme management, moving away from a purely class-based approach. This change fixes an issue with theme toggling. The logic is sound and the accompanying test updates correctly verify the new behavior. I've kept the suggestion to improve the efficiency of the toggleMode function by reducing redundant iterations over the element's class list, as it does not conflict with any provided rules.

@sonarqubecloud
Copy link

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.

2 participants

Comments