Changeset 8d054ca in Klonkt


Ignore:
Timestamp:
06/27/2026 01:39:08 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
923235e
Parents:
8951629
Message:

fix(ui): reply textareas no longer open huge (auto-resize skips hidden + caps height)

  • views/shell.ejs — the global textarea auto-resize measured scrollHeight even on textareas hidden inside a closed <details> (the fedi owner-reply box), producing a bad height that stuck as inline style so the field opened huge. Now it skips hidden textareas (they size on focus once visible) and respects a CSS max-height.
  • views/pages/post.ejs — give the comment/fedi-reply textarea a max-height (200px) so it opens at its min-height and scrolls past that instead of ballooning.
Location:
src/views
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/views/pages/post.ejs

    r8951629 r8d054ca  
    383383  resize: vertical;
    384384  min-height: 70px;
     385  max-height: 200px;
    385386  padding: 0.65rem 0.85rem;
    386387  border: 1px solid var(--rule);
  • src/views/shell.ejs

    r8951629 r8d054ca  
    684684  function autoSize(ta) {
    685685    if (!ta || ta.tagName !== 'TEXTAREA') return;
    686     ta.style.overflowY = 'hidden';
     686    // Skip hidden textareas (e.g. inside a closed <details> or an unopened reply
     687    // box): measuring scrollHeight there yields a bad height that sticks as inline
     688    // style and makes the field open huge. They get sized on focus once visible.
     689    if (ta.offsetParent === null && ta.offsetHeight === 0) return;
    687690    ta.style.height = 'auto';
    688     ta.style.height = ta.scrollHeight + 'px';
     691    var maxH = parseFloat(getComputedStyle(ta).maxHeight);
     692    var sh = ta.scrollHeight;
     693    var h = (maxH && !isNaN(maxH)) ? Math.min(sh, maxH) : sh;   // respect a CSS max-height
     694    ta.style.height = h + 'px';
     695    ta.style.overflowY = sh > h ? 'auto' : 'hidden';
    689696  }
    690697  function sizeAll(root) {
Note: See TracChangeset for help on using the changeset viewer.