From 7d41524b4afaa59b34a09a859b7782f2e5c237e6 Mon Sep 17 00:00:00 2001 From: KoloMl Date: Sun, 5 Apr 2026 19:21:09 +0400 Subject: [PATCH] Fixed scroll jump when preset becomes hidden --- src/content/components/philomena/TagsForm.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/content/components/philomena/TagsForm.ts b/src/content/components/philomena/TagsForm.ts index 606f149..f33d33e 100644 --- a/src/content/components/philomena/TagsForm.ts +++ b/src/content/components/philomena/TagsForm.ts @@ -196,7 +196,13 @@ export class TagsForm extends BaseComponent { ); const containerOffsetDifference = this.#presetsList.container.offsetTop - containerOffset; - const presetOffsetDifference = (targetElement?.offsetTop || 0) - presetOffset; + let presetOffsetDifference = (targetElement?.offsetTop || 0) - presetOffset; + + // If target element is no longer visible, then there is no need to apply scrolling fix, otherwise it will shift + // user up. Invisible elements are always report 0 offset. + if (targetElement?.checkVisibility() === false) { + presetOffsetDifference = 0; + } // Compensating for the layout shift: when user clicks on a tag (or on "add/remove all tags"), tag editor might // overflow the current line and wrap tags around to the next line, causing presets section to shift. We need to