Skip to content

fix: sidebar hint arrow now actually executes (st_components.html) - #28

Merged
SKOHscripts merged 1 commit into
mainfrom
claude/fix-sidebar-hint-js
May 26, 2026
Merged

fix: sidebar hint arrow now actually executes (st_components.html)#28
SKOHscripts merged 1 commit into
mainfrom
claude/fix-sidebar-hint-js

Conversation

@SKOHscripts

Copy link
Copy Markdown
Owner

$(cat <<'EOF'

Problem

The animated ↖ arrow hint was injected via st.markdown(..., unsafe_allow_html=True) which does not execute <script> tags — React sanitises them via dangerouslySetInnerHTML. The timer never fired, so the hint never appeared.

Fix

Switch to streamlit.components.v1.html(), which renders in a sandboxed iframe where JavaScript does execute. The script then reaches the main Streamlit page via:

  • window.parent.document — to inject the <style> and hint <div> into the real page DOM
  • window.parent.sessionStorage — to persist the "already visited" flag across re-renders
  • window.parent._sbHintInit — to prevent re-execution on Streamlit re-renders

The hint logic is otherwise unchanged: appears after 20 s if the sidebar has never been opened, disappears on sidebar click, never shown again once dismissed.

Test plan

  • Open the app without a database configured
  • Wait 20 seconds without clicking the sidebar toggle
  • Confirm the animated ↖ arrow with label appears at top-left
  • Click the sidebar toggle — confirm the arrow disappears
  • Reload — confirm the arrow does not reappear (sessionStorage flag set)

https://claude.ai/code/session_01VTBKKYLiAQ6mDPdmVhpRAT
EOF
)


Generated by Claude Code

st.markdown strips <script> tags (React sanitises them). Switch to
streamlit.components.v1.html() which renders in an iframe where JS
runs, then reach the parent page via window.parent.document and
window.parent.sessionStorage.

https://claude.ai/code/session_01VTBKKYLiAQ6mDPdmVhpRAT
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@SKOHscripts
SKOHscripts marked this pull request as ready for review May 26, 2026 20:21
@SKOHscripts
SKOHscripts merged commit 7f07964 into main May 26, 2026
3 checks passed
@SKOHscripts
SKOHscripts deleted the claude/fix-sidebar-hint-js branch May 26, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants