jamespdaily / pf2e-sheet-skill-actions

0 stars 14 forks source link

[BUG] Changing the quantity of any item in the inventory causes the inventory to jump to the top #39

Closed sorrythatuserbla closed 2 years ago

sorrythatuserbla commented 2 years ago

FVTT: V9 Build: 255 Pathfinder 2e: 3.7.0.10781 and earlier.

Active Modules: PF2e Character Sheet Skill Actions 0.9.0 and earlier

When you have scrolled down in the inventory and change any quantity of any item (+1 or -1) the scroll will reset to the top of the inventory.

Glunty commented 2 years ago

FVTT: V9 Build: 255 Pf2e : 3.7.2

Problem Reproduced.

I can't find the "faulty" code in pf2e-sheet-skill-actions : pf2e-sheet-skill-actions only registers on the hook "renderActorSheet" that gets called whenever an item is changed, a feat is added, a proficiency is changed... The character sheet stores the scroll position and restores it after the hook. This is a foundry core mechanism. This works fine for all tabs, except the inventory one. example :

A feat at the end of the list gets deleted image

The hook gets called, and the scroll position is at the top image

End of the hook, the scroll is restored to its position image

I played a bit with the system, but I'm not familiar enough with it to get to the root of the problem. I managed to reproduce it without the module pf2e-sheet-skill-actions activated, by removing ol.inventory-list from this code :

export abstract class ActorSheetPF2e<TActor extends ActorPF2e> extends ActorSheet<TActor, ItemPF2e> { static override get defaultOptions(): ActorSheetOptions { const options = super.defaultOptions; return mergeObject(options, { classes: options.classes.concat(["pf2e", "actor"]), scrollY: [".sheet-sidebar", ".tab.active", "ol.inventory-list"], }); } }

That made me think that pf2e system has a custom way of handling scroll position, that we're interfering with somehow.

jamespdaily commented 2 years ago

Yeah this is definitely rooted in the system code somewhere, not sure if there is a fix we can put in on this end that wouldn't interfere with the system code