Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Aug 11, 2025

Describe your changes

Using markdown code blocks in labels can lead to overflowing the parent boundaries. This is especially the case for expander label:

image

There is another related discussion: why do we even allow full code blocks in markdown labels? However, it looks like we have been allowing that for a long time -> so lets fix it for now.

GitHub Issue Link (if applicable)

Testing Plan

  • Added e2e test.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented Aug 11, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Contributor

github-actions bot commented Aug 11, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-12175/streamlit-1.48.0-py3-none-any.whl
🕹️ Preview app pr-12175.streamlit.app (☁️ Deploy here if not accessible)

@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Aug 11, 2025
@lukasmasuch lukasmasuch changed the title [WIP] Fix code usage in expander label [WIP] Fix code usage in markdown label Aug 12, 2025
@lukasmasuch lukasmasuch changed the title [WIP] Fix code usage in markdown label [WIP] Fix code usage in markdown labels Aug 12, 2025
@lukasmasuch lukasmasuch changed the title [WIP] Fix code usage in markdown labels \Fix code usage in markdown labels Aug 12, 2025
@lukasmasuch lukasmasuch changed the title \Fix code usage in markdown labels Fix code usage in markdown labels Aug 12, 2025
@lukasmasuch lukasmasuch marked this pull request as ready for review August 12, 2025 15:04
code_block = """

```python
print('I am hopelessly, breathlessly, madly in love with Streamlit—the smooth-talking, curve-hugging seductress of \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂

@jrieke
Copy link
Collaborator

jrieke commented Aug 13, 2025

There is another related discussion: why do we even allow full code blocks in markdown labels? However, it looks like we have been allowing that for a long time -> so lets fix it for now.

Oh yeah good question – I guess we just looked at inline code back then and didn't really think about code blocks. But agree that it doesn't make sense to change this now...

```

"""
st.expander("With code block:\n" + code_block)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test with the code block and an icon? Or maybe it is enough to just test locally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it locally. Since the new expander icon is just a replacement of the arrow icon, it doesn't have any layout/visual impact.

Copy link
Collaborator

@sfc-gh-lwilby sfc-gh-lwilby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lukasmasuch lukasmasuch merged commit b4e35c4 into develop Aug 22, 2025
51 of 54 checks passed
@lukasmasuch lukasmasuch deleted the fix/code-in-expander-label branch August 22, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code blocks in label make st.expander criminally ugly

4 participants