Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Fix tabs-scroller chevrons not appearing on cold load — the single initial requestAnimationFrame(update) was firing before the tab strip had settled its scrollWidth (FontAwesome icons not yet rendered, fonts not loaded), so scrollWidth-clientWidth measured as 0 and the right chevron's is-visible class was never added; now schedules multiple deferred measurements (rAF + 50ms + 300ms timeouts + window.load + document.fonts.ready) so any timing path produces a correct final measurement; ResizeObserver continues to drive ongoing updates after that

Murtaza Nasirfc2474f3ff9b
diff --git a/templates/components/page-header.html b/templates/components/page-header.html
index 68f63cbd..e520526e 100644
--- a/templates/components/page-header.html
+++ b/templates/components/page-header.html
@@ -120,8 +120,24 @@ document.addEventListener('click', function(e) {
} else {
window.addEventListener('resize', update);
}
- // Initial measure.
+
+ // Initial measure — run multiple times to catch fonts/images
+ // finishing layout. The first rAF can fire before the tab
+ // strip's true scrollWidth is settled (especially on cold
+ // load), which would leave the right chevron incorrectly
+ // hidden. A second pass on window.load and a third on a tiny
+ // timeout guarantees a correct measurement.
requestAnimationFrame(update);
+ setTimeout(update, 50);
+ setTimeout(update, 300);
+ if (document.readyState !== 'complete') {
+ window.addEventListener('load', update);
+ }
+ // Also respond when fonts finish loading (FontAwesome icons
+ // contribute width to each tab).
+ if (document.fonts && document.fonts.ready && document.fonts.ready.then) {
+ document.fonts.ready.then(update);
+ }
}
function initAll() {