flamewave000 / dragonflagon-fvtt

DragonFlagon FoundryVTT Modules
BSD 3-Clause "New" or "Revised" License
64 stars 62 forks source link

lib-df-buttons: Cannot set properties of undefined (setting 'active') #432

Open IHaveThatPower opened 1 year ago

IHaveThatPower commented 1 year ago

Module lib-df-buttons 1.4.2

Describe the issue On load of a world, the following error message appears (twice) in the console:

foundry.js:747 TypeError: Cannot set properties of undefined (setting 'active')
[Detected 1 package: lib-df-buttons]
    at ControlManager.getData (ControlManager.ts:168:15)
    at async ControlManager._render (foundry.js:5108:18)
    at async ControlManager._render (ControlManager.ts:263:3)

This doesn't seem to actually hurt anything, but it appears on every single world load/refresh.

To Reproduce

  1. Load a world with lib-df-buttons enabled.

Other DF modules loaded at the time: DF Curvy Walls, DF Settings Clarity

Expected behavior No errors in the console on load.

Error Location I traced the error itself to here:

        if (groups.every(x => !x.active)) {
            const firstGroup = groups.find(x => !x.button && !x.toggle);
            firstGroup.active = true;
            if (firstGroup)
                this.activateGroupByName(firstGroup.name);
        }

If this changes instead to:

        if (groups.every(x => !x.active)) {
            const firstGroup = groups.find(x => !x.button && !x.toggle);
            if (firstGroup)
            {
                firstGroup.active = true;
                this.activateGroupByName(firstGroup.name);
            }
        }

The error goes away. No other functionality seemed immediately impacted by the change.