Skip to content

Commit

Permalink
Fix access of current theme during page load
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSerth committed Aug 7, 2023
1 parent 44f725b commit 246cd20
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/assets/javascripts/color_mode_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ const setTheme = theme => {
})
document.dispatchEvent(event)
document.documentElement.setAttribute('data-bs-theme', currentTheme)
return currentTheme;
}

window.getCurrentTheme = () => {
return document.documentElement.getAttribute('data-bs-theme');
return document.documentElement.getAttribute('data-bs-theme') || setTheme(getPreferredTheme());
}

const showActiveTheme = (theme, focus = false) => {
Expand Down

0 comments on commit 246cd20

Please sign in to comment.