[Author Options] "Reset to Defaults" button comes back after reload
adamhl8 opened this issue ยท 2 comments
My WeakAura (link) has an issue where the "Reset to Defaults" button will come back after reloading despite all of the author options already being at their default value.
I've made a few other auras with author options and the issue does not occur with those.
I compared the exported lua tables before/after hitting the Reset to Defaults button, and there is no difference, so nothing is actually changing. Leading me to believe that it's not an issue with the way I've made this aura (there is nothing in the code that directly modifies the aura_env.config table), i.e., it seems to be a bug with WeakAuras
It seems to be related to adding a color option.
If you click on the color box and then click cancel in the color picker, the Reset button pops up despite nothing changing.
This is reproducible on any WeakAura.
After some more digging, I believe I've figured it out.
The allChoicesAreDefault
function in AuthorOptions.lua
checks if option.default =~ data.config[option.key]
, which compares the default values of an option to the current values of said option. This works fine for most things unless those things are tables.
In this particular case, because the color option's data is stored in a table, it ends up comparing two tables. So even though those two tables have the exact same data, the tables themselves are unique, making the function return false which causes the button to pop up.
Printing the tables and table values:
A solution would be to check the type of those two things and if they're tables, loop through each table and check if they contain the same values.