fix: restore composer block height in layout px (zoom-aware)

Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
FactorandOvis Fast committed 2026-11-19 11:57:06 +01:00
1 parent 6678cd3dc8
commit 611831b008
1 file changed
+32 -5
+32 -5
View File
@@ -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 {