Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display issue with multi-line strings in st.toast - text written over the view more option #8330

Closed
3 of 4 tasks
mkleinbort-ic opened this issue Mar 19, 2024 · 2 comments · Fixed by #8337
Closed
3 of 4 tasks
Labels
feature:st.toast priority:P3 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working

Comments

@mkleinbort-ic
Copy link

mkleinbort-ic commented Mar 19, 2024

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

When the text passed to st.toast is long and has explicit line breaks, the logic that prevents the text being written over the view more option does not work.

image

Reproducible Code Example

Open in Streamlit Cloud

import streamlit as st

long_text_with_explicit_line_breaks = '''
Call me Ishmael. 
Some years ago—never mind how 
long precisely—having little 
or no money in my purse, and nothing 
particular to interest me on shore, 
I thought I would sail about a little 
and see the watery part of the world. 
It is a way I have of driving off the spleen and 
regulating the circulation. 
Whenever I find myself growing grim about the mouth; 
whenever it is a damp, drizzly November in my soul; 
whenever I find myself involuntarily pausing before 
coffin warehouses, and bringing up the rear of every funeral I meet
'''

long_text_with_no_line_breaks = long_text_with_explicit_line_breaks.replace('\n', ' ')

st.toast(long_text_with_no_line_breaks)
st.toast(long_text_with_explicit_line_breaks)

Steps To Reproduce

No response

Expected Behavior

No response

Current Behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version:
  • Python version:
  • Operating System:
  • Browser:

Additional Information

No response

@mkleinbort-ic mkleinbort-ic added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels Mar 19, 2024
Copy link

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

@mkleinbort-ic mkleinbort-ic changed the title Display issue with multi-line strings in st.toast - text written over the show more option Display issue with multi-line strings in st.toast - text written over the view more option Mar 19, 2024
@sfc-gh-lmasuch sfc-gh-lmasuch added status:confirmed Bug has been confirmed by the Streamlit team priority:P3 feature:st.toast and removed status:needs-triage Has not been triaged by the Streamlit team labels Mar 20, 2024
@LukasMasuch
Copy link
Collaborator

@mkleinbort-ic Thanks for reporting this issue. I reproduced this here.

vdonato pushed a commit that referenced this issue Mar 25, 2024
)

This PR ensures consistent toast message truncation at the character limit, to avoid overflowing like #8330.

- Modified the `shortenMessage` truncation by preserving whole words while adhering to the character limit
- Also, trimmed the resulting string to ensure no leading or trailing whitespace
- Lastly, exported the function to make it available for testing

Closes #8330.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:st.toast priority:P3 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants