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 console error in examples pages due to no theme switcher #38074

Merged
merged 1 commit into from
Feb 17, 2023

Conversation

julien-deramond
Copy link
Member

@julien-deramond julien-deramond commented Feb 17, 2023

Description

This PR checks in color-mode.js that the themeSwitcher var is not null before continuing the algorithm.

Motivation & Context

This avoids an error message in the console when one goes to any examples in our doc (e.g. https://twbs-bootstrap.netlify.app/docs/5.3/examples/heroes/) either in light or dark mode:

Uncaught TypeError: btnToActive is null
    showActiveTheme https://twbs-bootstrap.netlify.app/docs/5.3/assets/js/color-modes.js:35
    <anonymous> https://twbs-bootstrap.netlify.app/docs/5.3/assets/js/color-modes.js:60
color-modes.js:35:28

This is because our examples react to the theme being light or dark via color-modes.js, but they don't have any dropdown switcher on the page (like in the header for other pages).

Type of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • (N/A) I have added tests to cover my changes
  • All new and existing tests passed

Live previews

@julien-deramond julien-deramond marked this pull request as ready for review February 17, 2023 05:53
@julien-deramond julien-deramond requested a review from a team as a code owner February 17, 2023 05:53
@julien-deramond julien-deramond changed the title Fix console error in examples pages du to no theme switcher Fix console error in examples pages due to no theme switcher Feb 17, 2023
@XhmikosR XhmikosR merged commit 3122127 into main Feb 17, 2023
@XhmikosR XhmikosR deleted the main-jd-fix-console-error-in-examples-pages branch February 17, 2023 06:56
@mahilanmjd mahilanmjd mentioned this pull request Apr 16, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants