MudBlazor / TryMudBlazor

A playground for trying out and testing MudBlazor components entirely in the browser.
https://try.mudblazor.com/
GNU General Public License v2.0
75 stars 37 forks source link

Editor showing default theme on first load #130

Open benbaker76 opened 5 months ago

benbaker76 commented 5 months ago

When you load the UserPage for the first time the editor will be themed default and the rest will be in vs-dark mode. I tried the following change:

        create: function (id, value, language) {
            if (!id) { return; }
            let _theme = "vs-dark"; // was "default"
            let userPreferences = localStorage.getItem("userPreferences");
            if (userPreferences) {
                const userPrefer
encesJSON = JSON.parse(userPreferences);
                if (userPreferencesJSON.hasOwnProperty("DarkTheme") && userPreferencesJSON.DarkTheme) {
                    _theme = "vs-dark";
                }

Which appears to fix it at first until you refresh the page when you have the theme set to default. The editor shows in vs-dark mode. The problem appears to be a failure to load the setting properly when you refresh or when there's no userPreferences set.

Screenshot from 2024-03-27 08-20-25