T
TyphonJSWHITESPINE

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:
// Applications which are not currently rendered must be forced
if ( !force && (this._state <= states.NONE) ) return;
// Applications which are not currently rendered must be forced
if ( !force && (this._state <= states.NONE) ) return;
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.
TM
TyphonJS (Michael)279d ago
Can you add that gating lines found in Application._render to the top of SvelteApplication._render. IE add:
// Do not render under certain conditions
const states = Application.RENDER_STATES;
if ( [states.CLOSING, states.RENDERING].includes(this._state) ) return;

// Applications which are not currently rendered must be forced
if ( !force && (this._state <= states.NONE) ) return;
// Do not render under certain conditions
const states = Application.RENDER_STATES;
if ( [states.CLOSING, states.RENDERING].includes(this._state) ) return;

// Applications which are not currently rendered must be forced
if ( !force && (this._state <= states.NONE) ) return;
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.
W
WHITESPINE278d ago
Solution as posted didn't exactly work - gonna iterate on it a bit. Solution worked, thanks. Just had to delete vite-cache. Also discovered another minor issue: When drag re-ordering an item in the items sidebar tab, if that item is configured to use a TJSApplication sheet, it will cause the following error: Uncaught (in promise) TypeError: doc.sheet.submit is not a function Due to the following foundry behavior:
async sortRelative({updateData={}, ...sortOptions}={}) {
const sorting = SortingHelpers.performIntegerSort(this, sortOptions);
const updates = [];
for ( let s of sorting ) {
const doc = s.target;
const update = foundry.utils.mergeObject(updateData, s.update, {inplace: false});
update._id = doc._id;
if ( doc.sheet && doc.sheet.rendered ) await doc.sheet.submit({updateData: update}); // <------------- HERE!
else updates.push(update);
}
if ( updates.length ) await this.constructor.updateDocuments(updates, {parent: this.parent, pack: this.pack});
return this;
}
async sortRelative({updateData={}, ...sortOptions}={}) {
const sorting = SortingHelpers.performIntegerSort(this, sortOptions);
const updates = [];
for ( let s of sorting ) {
const doc = s.target;
const update = foundry.utils.mergeObject(updateData, s.update, {inplace: false});
update._id = doc._id;
if ( doc.sheet && doc.sheet.rendered ) await doc.sheet.submit({updateData: update}); // <------------- HERE!
else updates.push(update);
}
if ( updates.length ) await this.constructor.updateDocuments(updates, {parent: this.parent, pack: this.pack});
return this;
}
I assume this is just because TJSApplication was really just meant to replace Application, not FormApplication, and is thus missing some functionality. An eventual TJSDocumentSheet (or something) would hopefully resolve it - in the meantime I am not super concerned, item sorting isn't exactly mission critical Oh wait - editing things in node_modules doesn't seem to immediately apply the changes in browser - even after restarting dev server / explicitly running npm run build Had to edit vite cache Mostly solved :)
TM
TyphonJS (Michael)277d ago
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.
W
WHITESPINE277d ago
Oh right I forgot I can just define that in my subclass. Yeah that's the only remaining issue
TM
TyphonJS (Michael)249d ago
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.
W
WHITESPINE249d ago
monkyippee thanks
Want results from more Discord servers?
Add your server
More Posts
TJSDocumentCollection best practices?Hi! I've got a little component I'm using whose purpose is basically to just show a tiny preview of Release `TRL 0.1.1` - Patch releaseGreets @FVTT ▹ Developer! I have just released a patch / fix release that fixes a small oversight iUncaught TypeError: $storeElementRoot is undefinedHi! Encountering the following error when trying to resize an application based on a TJSApplicationSPopcorn InitiativeJust opening a forum post to track @gerark progress w/ TRL & Svelte + an initial idea of implementinToken Action HUDLet's continue chatting about TAH here to keep track of discussion @larkinaboutPostcssConfig seem not workin with 0.1.0@mleahy sorry to bother i'm trying to use the postccs feature of the @typhonjs-fvtt/runtime on the TJSDocument for aggregating actor flags for Svelte ComponentI'm sure this is very simple, but I'm having a hard time understanding how to get this to work. MaybUpdate to ChatMessage outside of Svelte doesn't trigger reactivity on linked TJSDocumentI'm a bit confused about this... 1. When I render a ChatMessage via svelte, in the chat message sveRelease `TRL 0.1.0` - The journey to beta begins...Greets @FVTT ▹ Developer, I am very excited to announce the release of TRL `0.1.0`. This is a majorHow do I get the elementRoot of a ChatMessage?SvelteApplication provides `elementRoot` prop to components that implement it, which is very useful.Getting started with the GUI and understanding element rootIt's been a while, but I've been working on my Knowledge Recalled module since V11 is out, and my frDrag & Drop broke in v11Ok so something that broke for me when moving to v11 is drag&drop from both the items tab of the sidTJSDocument and Token Issues```js const tokens = cardData.targets .map(t => [t, fromUuidSync(t)]) .filter(([_, tSyrinControl & Svelte...I gather there is a bit to discuss... 😄Ver .11Not sure if this is the place to ask, but updated to v .7.11 foundry 10. Lost all quest data. FoldePackage Release: Foundry Summons (3rd party)Greets @everyone. I do try to use pings sparingly, but want to show a spotlight on @vauxs new packagCreating an interim TJSDocument / document attribute bridgeHi @wasp... Just moving discussion here as it is a better forum post. > So I have made a system wiTJSGameSettings with not registered settings.I am not sure what is happening in here. I have created an attachement to the existing Settings pagStoring a collection of Items in an Item?Use cases would be: - containers could contain other Items - some items have prerequisites, which coRelease: Quest Log `0.7.12`Greets @FVTT ▹ Quest Log! The v11 compatibility release is now available from the Foundry package m