Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Anchor toast notifications to the top-right of the work-area bounds (#mainContentColumns) — same single-source-of-truth pattern the floating chat uses so toasts move consistently when the layout shifts (sidebar collapse, column resize, audio player top↔bottom, mobile bottom-nav, viewport resize) instead of staying glued to the viewport corner above the sidebar gutter; ResizeObserver on the columns element drives positioning, window.resize covers the fallback path, a short retry loop after mount catches the case where Vue creates #mainContentColumns AFTER the script runs (e.g. when navigating into the detail view); when the columns element isn't on the page at all (settings / admin / inquire / list view) the container falls back to the viewport top-right corner gracefully; no Vue refactor — the container stays as plain HTML inside the Vue app and the toast.js utility keeps appending children to it as before
Murtaza Nasir7adcb11f7473
diff --git a/templates/modals/toast-container.html b/templates/modals/toast-container.htmlindex 1c977e6c..9ee4bff7 100644--- a/templates/modals/toast-container.html+++ b/templates/modals/toast-container.html@@ -1,2 +1,68 @@-<!-- Toast Container -->-<div id="toastContainer" class="fixed top-4 right-4 z-50 pointer-events-none"></div>+<!-- Toast Container.++ Anchored to the TOP-RIGHT of the active work area (#mainContentColumns)+ when present — same single source of truth the floating chat uses, so+ any layout change that affects the chat bounds also moves the toasts+ consistently (sidebar collapse, column resize, audio player flip+ top↔bottom, mobile bottom-nav presence, viewport resize). Falls back+ to the viewport top-right corner when #mainContentColumns isn't on+ the page (e.g. settings, admin, inquire).++ Implementation note: the container is fixed-positioned, with top + right+ offsets computed from the columns rect. A ResizeObserver on the columns+ element handles size changes and window-resize handles the fallback. -->+<div id="toastContainer" class="fixed z-50 pointer-events-none"+ style="top: 16px; right: 16px;"></div>++<script>+(function () {+ var INSET = 16;+ var container = document.getElementById('toastContainer');+ if (!container) return;++ function update() {+ var anchor = document.getElementById('mainContentColumns');+ if (anchor) {+ var r = anchor.getBoundingClientRect();+ // When the columns are off-screen (e.g. on a tab without the+ // detail view), fall back to the viewport corner.+ if (r.width > 0 && r.bottom > 0 && r.top < window.innerHeight) {+ container.style.top = Math.max(0, r.top + INSET) + 'px';+ container.style.right = Math.max(0, (window.innerWidth - r.right) + INSET) + 'px';+ return;+ }+ }+ container.style.top = INSET + 'px';+ container.style.right = INSET + 'px';+ }++ // Initial position.+ update();++ // React to any change of the work-area bounds. ResizeObserver fires+ // when the observed element's size changes; window.resize covers the+ // fallback case where #mainContentColumns isn't present yet (Vue+ // mounts later) and also fires reliably on viewport resize.+ var observed = null;+ function ensureObserver() {+ if (typeof ResizeObserver === 'undefined') return;+ var anchor = document.getElementById('mainContentColumns');+ if (!anchor || anchor === observed) return;+ observed = anchor;+ new ResizeObserver(update).observe(anchor);+ }++ // Window resize covers fallback + size changes the observer doesn't.+ window.addEventListener('resize', update, { passive: true });++ // #mainContentColumns is created by Vue after mount. Retry attaching+ // the observer for a short window so we don't miss the late mount.+ ensureObserver();+ var attempts = 0;+ var retryTimer = setInterval(function () {+ ensureObserver();+ update();+ if (++attempts >= 20 || observed) clearInterval(retryTimer);+ }, 150);+})();+</script>