fix: delay dark mode loading to bypass vuetify bug (#1877)

This commit is contained in:
Michael Genson 2022-12-04 13:30:02 -06:00 committed by GitHub
parent 6111f9c88c
commit 0e1d778d3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,10 @@ import { useDark } from "@vueuse/core";
const darkModePlugin: Plugin = ({ $vuetify }, _) => {
const isDark = useDark();
$vuetify.theme.dark = isDark.value;
// Vuetify metadata is bugged and doesn't render dark mode fully when called immediately
// Adding a 0.5 millisecond delay fixes this problem
// https://stackoverflow.com/questions/69399797/vuetify-darkmode-colors-wrong-after-page-reload
setTimeout( () => { $vuetify.theme.dark = isDark.value; }, 0.5);
};
export default darkModePlugin;