Issue 104 Fix. ContextMenu trying to render inside constructor #147
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type
What type of pull request is this? (e.g., Bug fix, Feature, Refactor, etc.)
Description
The ListComponents were calling the .create() method of AppContextMenu before their own element objects were fully initialized. This caused the error as .AppendChild was clearly not available inside of the ContextMenu create() method. I've changed this functionality to take place in _onRender instead of _onInitialize to ensure better timing of the element initializations. I also implemented some cleanup methods _onDestroy in the ListComponents which properly cleans up their ContextMenus, Thanks Claude!
Related Issue
Fixes Issues #104
How Has This Been Tested?
Opening, closing and opening a character sheet any number of times. Also adding objects to each of the lists still saves and reloads on subsequent restarts of Foundry.
Checklist: