Changeset f6b2c68 in Klonkt


Ignore:
Timestamp:
06/26/2026 04:49:12 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
9327a85
Parents:
1c85964
Message:

fix(ios-pwa): pad body for safe-area when masthead is hidden on mobile

Root cause (found via on-device debug): <=767px the masthead is display:none
(bottom-tab replaces it), so its safe-area padding has no effect (height 0) and the
profile-header lands at top=0 behind the Dynamic Island. Landscape (>767px) shows the
masthead so it worked there. Fix: pad body:not(.on-admin) by --ios-safe-top in the same
mobile media query, and make the JS adaptive (masthead hidden -> force body padding,
else masthead). Removed the temporary debug overlay; SW cache -> v14.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/server.js

    r1c85964 rf6b2c68  
    395395  res.set('Cache-Control', 'no-cache');
    396396  res.send(`
    397 const CACHE_VERSION = 'pcms-v13-' + new Date().toISOString().split('T')[0];
     397const CACHE_VERSION = 'pcms-v14-' + new Date().toISOString().split('T')[0];
    398398self.addEventListener('install', e => {
    399399  e.waitUntil(caches.open(CACHE_VERSION).then(c => c.addAll(['/'])));
  • src/views/partials/topnav.ejs

    r1c85964 rf6b2c68  
    328328@media (max-width: 767px) {
    329329  body:not(.on-admin) .masthead { display: none; }
     330  /* The masthead is gone on mobile, so it can't carry the iOS safe-area top inset
     331     (env() resolves to 0 in the home-screen PWA; --ios-safe-top is set by JS in shell).
     332     Pad the body instead so the profile-header clears the Dynamic Island / notch. */
     333  body:not(.on-admin) { padding-top: var(--ios-safe-top, 0px); }
    330334}
    331335
  • src/views/shell.ejs

    r1c85964 rf6b2c68  
    223223    document.documentElement.style.setProperty('--ios-safe-top', i + 'px');
    224224    var mh = document.querySelector('.masthead');
    225     if (mh) mh.style.paddingTop = 'calc(.55rem + ' + i + 'px)';
    226     /* TEMP DEBUG — remove after diagnosing the iOS PWA safe-area. Tap to dismiss. */
    227     var d = document.getElementById('ios-dbg');
    228     if (!d) { d = document.createElement('div'); d.id = 'ios-dbg'; d.onclick = function(){ d.remove(); };
    229       d.style.cssText = 'position:fixed;left:6px;bottom:96px;z-index:2147483647;background:rgba(0,0,0,.86);color:#0f0;font:11px/1.4 monospace;padding:7px 9px;border-radius:6px;white-space:pre;max-width:92vw';
    230       document.body.appendChild(d); }
    231     var ph = document.querySelector('.profile-header') || document.querySelector('#pcms-chrome');
    232     var mr = mh ? mh.getBoundingClientRect() : null;
    233     var pr = ph ? ph.getBoundingClientRect() : null;
    234     var mhCS = mh ? getComputedStyle(mh) : null;
    235     d.textContent = 'env=' + rawEnv + '  final=' + i + '  standalone=' + standalone
    236       + '\nscreen=' + screen.width + 'x' + screen.height + ' dpr=' + window.devicePixelRatio + ' scrollY=' + Math.round(window.scrollY)
    237       + '\nmh: pos=' + (mhCS ? mhCS.position : '-') + ' pad=' + (mhCS ? Math.round(parseFloat(mhCS.paddingTop)) : '-') + ' top=' + (mr ? Math.round(mr.top) : '-') + ' h=' + (mr ? Math.round(mr.height) : '-')
    238       + '\nchrome/profile top=' + (pr ? Math.round(pr.top) : '-') + ' body.pt=' + Math.round(parseFloat(getComputedStyle(document.body).paddingTop));
     225    var mhHidden = !mh || getComputedStyle(mh).display === 'none' || mh.offsetHeight === 0;
     226    if (mhHidden) {
     227      /* Mobile: the masthead is hidden (bottom-tab replaces it ≤767px) so it can't carry
     228         the inset. Pad the body instead → the profile-header clears the island/notch. */
     229      document.body.style.paddingTop = i + 'px';
     230      if (mh) mh.style.paddingTop = '';
     231    } else {
     232      /* Desktop/landscape: the sticky masthead carries the inset in its own padding. */
     233      document.body.style.paddingTop = '';
     234      mh.style.paddingTop = 'calc(.55rem + ' + i + 'px)';
     235    }
    239236  }
    240237  if (document.body) apply(); else document.addEventListener('DOMContentLoaded', apply);
Note: See TracChangeset for help on using the changeset viewer.