From 24ee0213147b4134bbbaee9441074e0ed95ba4a1 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 May 2026 16:07:07 +0000 Subject: [PATCH] fix(footer): hide the helper page_link row that was leaking into pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same wrong-testid bug as the Close click handler: the CSS rule that's supposed to position the hidden ``st.page_link`` off-screen was selecting ``a[data-testid="stPageLink"]``, but the bare ``stPageLink`` testid is on the OUTER wrapper div — the anchor uses ``stPageLink-NavLink``. ``:has(a[data-testid="stPageLink"]...)`` matched nothing, so the helper rendered as a full-size visible row at the bottom of every page (the "large white bar blocking content" the user reported). Fix: switch both the ``:has()`` rule and the no-:has() fallback to ``a[data-testid="stPageLink-NavLink"][href*="close"]``. The ``href*="close"`` form also works for base-path deployments (``/myapp/close``), matching the click handler's selector. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/gui/components/_legacy.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gui/components/_legacy.py b/src/gui/components/_legacy.py index 88b81e1..18e5401 100644 --- a/src/gui/components/_legacy.py +++ b/src/gui/components/_legacy.py @@ -734,9 +734,15 @@ def render_sticky_footer() -> None: Streamlit's soft nav (preserves the websocket, no visible page reload) instead of the browser hard-nav an ```` would trigger. Off-screen (rather than ``display:none``) so - React event delegation works reliably across browsers. */ -[data-testid="stElementContainer"]:has(a[data-testid="stPageLink"][href$="/close"]), -[data-testid="stElementContainer"]:has(a[data-testid="stPageLink"][href$="/close/"]) { + React event delegation works reliably across browsers. + + NOTE on the selector: Streamlit's page_link renders an outer + wrapper div with ``data-testid="stPageLink"`` and an inner anchor + with ``data-testid="stPageLink-NavLink"`` — the NavLink suffix + is required to match the anchor (the bare testid is on the + wrapper). ``href*="close"`` works across both root (``/close``) + and base-path (``/myapp/close``) deployments. */ +[data-testid="stElementContainer"]:has(a[data-testid="stPageLink-NavLink"][href*="close"]) { position: absolute !important; left: -9999px !important; top: -9999px !important; @@ -747,9 +753,9 @@ def render_sticky_footer() -> None: pointer-events: none !important; } /* Defensive fallback for browsers without :has() — at least - shrink the inline page_link so it doesn't render a visible row. */ -a[data-testid="stPageLink"][href$="/close"], -a[data-testid="stPageLink"][href$="/close/"] { + shrink the inline page_link so it doesn't render a visible row. + Same testid note as above. */ +a[data-testid="stPageLink-NavLink"][href*="close"] { visibility: hidden !important; height: 0 !important; padding: 0 !important;