TJSApplication Character Sheet odd behavior with unlinked tokens
Has anyone else experienced weird when using a TJSApplication as a character sheet with unlinked tokens? In my system, updating the base actor attempts to render the actor sheet for every token on the scene, regardless of whether that token's sheet was open previously. Every token whose sheet hasn't been rendered yet, will cause a fairly predictable "TypeError: An error occurred while rendering TJSDocSheet 45. this._element is null" - the sheet isn't mounted anywhere, so big surprise there. All other sheets will be made visible simultaneously. I think the SvelteApplication _render is missing the following check from foundry.js:
Which requires force=true to summon a closed sheet, as foundry seems like it will frequently render with
force=false
as a way to update any open sheets. Without this check, any of these "update" renders will cause undesired behavior.6 Replies
Can you add that gating lines found in
Application._render
to the top of SvelteApplication._render
.
IE add:
to the top of SvelteApplication._render
.
There is a chance that this logic was added after SvelteApplication was created and I didn't catch the changes to Application._render
. Basically the same conditions that should stop an Application._render
process should stop any further logic occurring in SvelteApplication._render
.
You should be able to just put that bit of code in the node_modules/@typhonjs-fvtt/runtime/_dist/svelte/application/SvelteApplication.js
code and rebuild and let me know if things work.
There also is a chance that the logic added to core around unlinked tokens re: invoking render without force
was recently added which now causes this situation and without the extra gating in SvelteApplication._render
the problem arises.
I can add this and the TJSGlassPane enhancements to a new release soon.Yeah, the dev server is going to get caught up w/ caching and such. I should have mentioned to make the mod locally and then use production builds to test as the Rollup / production build will pull in any local changes to
node_modules
.
When you say it's mostly solved
I take it that the gating solves the non-forced render of sheets that aren't yet visible.
The remaining part is that sheets in core Foundry have the update submit
method / are FormApplications thus in any system implementation it's necessary to mirror some parts of the Foundry / FormApplication API so that things play nice w/ the core implementation. This is something that can be addressed in adding an exported submit
function from the main JS implementation for a sheet.Oh right I forgot I can just define that in my subclass. Yeah that's the only remaining issue
I will try and get that extra gating into an update this week. This should solve the unlinked token / aspects where Foundry is just cycling through all
ui.windows
/ or the token / document sheets and bashing a non-forced render.
The problem likely occurred here for non-visible / not currently rendered apps / sheets:
https://github.com/typhonjs-fvtt-lib/svelte/blob/main/src/application/SvelteApplication.js#L890
Where the options are being applied to the position system, but the main element is null / since it's not a rendered sheet. The gating in Application._render
stops a render, but simply returns and I have to add the same behaviour into SvelteApplication._render
to stop further processing.
This should be fixed w/ TRL 0.1.2; IE render: false
w/ non-rendered apps should not properly function. thanks