Skip to content

Commit

Permalink
fix(ui): useDetectTheme not updating if it was not auto
Browse files Browse the repository at this point in the history
  • Loading branch information
itsjavi committed Aug 30, 2023
1 parent 247c2b5 commit a2c38c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/storylite/src/app/hooks/useDetectTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export function useDetectTheme(): string {
const isAuto = params.theme.value === 'auto' || !params.theme.value

if (!isAuto) {
document.body.setAttribute(themeAttrName, String(params.theme.value ?? ''))
const value = String(params.theme.value ?? '')
document.body.setAttribute(themeAttrName, value)
setDetectedTheme(value as SLColorScheme)

return
}
Expand All @@ -35,7 +37,7 @@ export function useDetectTheme(): string {
return () => {
mediaQuery.removeEventListener('change', handleThemeChange)
}
}, [params])
}, [params.theme.value, userConfig.themeAttribute])

return detectedTheme
}

0 comments on commit a2c38c5

Please sign in to comment.