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, hc,
home, home,
run, run,
settings,
shared, shared,
setShared, setShared,
notify, 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 // 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. // panel is open, and goes back to its height when the panel closes. The
this.panelRestorePx = null; // height is remembered once, BEFORE the resize, in the units `layout.resize`
if (Number.isFinite(this.blockHeight) && this.blockHeight < PANEL_MIN_BLOCK) { // takes (see `layoutPx`), and nothing overwrites it while the panel is open.
this.resizeBlock(PANEL_BLOCK_PX); if (this.panelRestorePx === null) {
this.panelRestorePx = Math.round(this.blockHeight); 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); this.favorites = storage.loadFavorites(this.store);
@@ -645,6 +650,28 @@ export default class Composer extends View {
if (restore) this.restoreSelection(caret); 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. */ /** The composer block gets another height (`layout.resize`); a refusal is said, not worked around. */
resizeBlock(px) { resizeBlock(px) {
try { try {