diff --git a/mod/ovis-composer/main.js b/mod/ovis-composer/main.js index aeb9793..6005937 100644 --- a/mod/ovis-composer/main.js +++ b/mod/ovis-composer/main.js @@ -29,6 +29,7 @@ import { hc, home, run, + settings, shared, setShared, notify, @@ -618,11 +619,15 @@ export default class Composer extends View { } // A low block leaves no room for a list: it is made taller while the - // panel is open, and goes back to its height when the panel closes. - this.panelRestorePx = null; - if (Number.isFinite(this.blockHeight) && this.blockHeight < PANEL_MIN_BLOCK) { - this.resizeBlock(PANEL_BLOCK_PX); - this.panelRestorePx = Math.round(this.blockHeight); + // panel is open, and goes back to its height when the panel closes. The + // height is remembered once, BEFORE the resize, in the units `layout.resize` + // takes (see `layoutPx`), and nothing overwrites it while the panel is open. + if (this.panelRestorePx === null) { + const px = this.layoutPx(); + if (px !== null && px < PANEL_MIN_BLOCK) { + this.panelRestorePx = px; + this.resizeBlock(PANEL_BLOCK_PX); + } } this.favorites = storage.loadFavorites(this.store); @@ -645,6 +650,28 @@ export default class Composer extends View { if (restore) this.restoreSelection(caret); } + /** + * The height of the block in the pixels of the layout (`layout.resize {px}`). + * + * The root reports LOGICAL pixels - the layout's pixels times the zoom of + * the app (settings().zoom, 1.2 here: 260 px in the layout is 312 reported). + * Giving the reported number back to `layout.resize` would make the block + * taller by the zoom factor, so it is divided by it. + * + * @returns {number|null} null while the root has not reported a height + */ + layoutPx() { + if (!Number.isFinite(this.blockHeight)) return null; + let zoom = 1; + try { + const value = Number(settings()?.zoom); + if (Number.isFinite(value) && value > 0) zoom = value; + } catch { + // Unknown zoom: 1, the reported height is taken as it is. + } + return Math.round(this.blockHeight / zoom); + } + /** The composer block gets another height (`layout.resize`); a refusal is said, not worked around. */ resizeBlock(px) { try {