Fix plugin-breaking bug by validating "variable-number" input before saving it#189
Conversation
|
Apologies for the double ping @mgmeyers, but according to discord messages people are still getting their Obsidian broken due to this bug, and most importantly they are always unaware of the root cause, and consequently clueless as to how to fix it. This PR makes minimal changes to a single arrow function in one file, and merging it would resolve this plugin-breaking issue without introducing any bugs, based on my testing. I know you are busy, so if you require any changes before merging, I'd be happy to make them, just let me know. Thank you! |
|
Is there any follow-up? Why does the author, @mgmeyers, not invite other developers to maintain this great plugin? I can understand he may be very busy. But then he can leave room for others to at least maintain it and resolve incompatibility bugs that may occasionally arise. Any thoughts how to best proceed? |
Summary
This PR adds input validation before saving values in
variable-numbertype input fields, fixing a critical bug that breaks the plugin, with the only remedy being a complete reinstall of the StyleSettings plugin.Explanation
The current code allows users to enter and save non-numerical values into the
variable-numbersetting field. When this happens, aNaNvalue is saved to the CSS variable (due toisFloat ? parseFloat(value) : parseInt(value, 10)), which then turns intonull. This is incredibly problematic, as once this happens the user loses the ability to edit this CSS variable, as StyleSettings does not display settings for that variable and any similar variables anymore, as it does not think it's a valid setting at that point.Reproduction example:
In a new vault, install the Border theme (it works with any theme though), and StyleSettings.
In Style Settings options go to Editor->Headings->Level 1 Headings, and enter any non-numerical value into the
H1 font weightsetting. Such asasd,a600,hfsdaf, or similar.Restart Obsidian
Observe that the setting you just changed is no longer functional. You can type, but it doesn't save anything entered into it anymore, as it's broken. Also, related variable settings are completely gone either.
In this example, the following StyleSetting is saved:
And since this setting makes the h1-weight input field non-functional, along with all related input fields, the plugin is irreversibly broken and can only be fixed with a full reinstall.
@mgmeyers