Fix variables form dialog resize glitch for templates with many variables - #179
Open
PriyankaaXD wants to merge 1 commit into
Open
PriyankaaXD wants to merge 1 commit into
PriyankaaXD wants to merge 1 commit into
Conversation
Fixes the variables form dialog resize glitch reported in joplin#59. The dialog previously relied on Joplin's default auto-resize-to-content behavior (setFitToContent: true), which raced with the form's own max-height/overflow CSS and caused a visible grow-then-shrink glitch when many variables were present. Since the dialog handle is created once and reused across template uses, fit-to-content must be explicitly set on every open rather than only conditionally disabled - otherwise the mode from a previous template's dialog use would leak into the next one regardless of its own variable count. Now setFitToContent is explicitly set every time based on the current template's variable count: true (compact, auto-sized) for 5 or fewer variables, false (fixed 90vw x 80vh, scrollable) for more than 5.
Author
|
Happy to make any changes if you'd like a different threshold or approach. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #59
Problem
As reported by @amandamcg in the discussion on #59, the fix in 0aa28b4 (max-height + overflow scroll on
.variablesForm) didn't fully solve the issue — the dialog would open short, grow, then slowly contract, instead of opening at a stable size. This happens because the dialog was left at Joplin's defaultsetFitToContent: true, so the core app auto-resizes the iframe to content height dynamically, which races against the plugin's own CSS max-height constraint.Fix
Explicitly call
joplin.views.dialogs.setFitToContent(this.dialog, ...)on every dialog open, based on the current template's variable count —true(compact, auto-sized) for 5 or fewer variables,false(fixed 90vw x 80vh, scrollable) for more than 5.Note: this must be set explicitly every time, not only conditionally disabled, because the dialog handle (
dialogViewHandle) is created once inindex.tsand reused across every template use. An earlier version of this fix only calledsetFitToContent(false)when variable count was high, which caused thefalsestate to leak into the next dialog use even when that template had few variables. Setting it explicitly on every open avoids this.Testing
Tested manually on Windows, across multiple orderings in the same session:
Screenshots below show both cases.
[ test2 - 3 variables, compact dialog]


[Test Template - Many Vars - 18 variables, stable scrollable dialog]