Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Jul 10, 2023

Describe your changes

Currently, messages are cut off when st.chat_input is used in an embedded app. To fix this, we are always using the 10rem bottom padding regardless if it is embedded or not if the app is using chat_input.

Note: This is more of a quick fix. We eventually want to refactor how chat input in fullscreen mode interacts with the app view (e.g. introduce a bottom container).

Current state:

image

After the change:
image


Contribution License Agreement

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

@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 Jul 10, 2023
className="block-container"
data-testid="block-container"
isWideMode={wideMode}
showPadding={showPadding}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why could we not just do:

showPadding={showPadding || containsChatInput} with a comment?

Copy link
Collaborator Author

@lukasmasuch lukasmasuch Jul 10, 2023

Choose a reason for hiding this comment

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

I think this would also add the header padding, which we don't want in this case. If it is embedded and has a chat input, we only want the bigger bottom padding.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would then be addPaddingForHeader={(showToolbar || showColoredLine) && !containsChatInput} then?

Copy link
Collaborator Author

@lukasmasuch lukasmasuch Jul 10, 2023

Choose a reason for hiding this comment

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

hmm, addPaddingForHeader is adding a 3rem top padding instead of 1rem.

image

It would probably mostly work fine, but it would impact apps like the one embedded on the docs page here (which doesn't have a toolbar / color line)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm also fine with this solution. But I think we anyways need to refactor this a bit on how the "fullscreen" chat input works together with the AppView (-> I would love to move it to some kind of bottom root container). So the addPaddingForChatInput is probably more of a temporary change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alright. I am fine with it. Can we add a screenshot test then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This could be a bit tricky since we don't have precedence (as far as I know) for e2e testing embedded apps. But I will take another look into this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can check out #5894 which shows an example of the iframe resizer working.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ahh, didn't know about this one. Already added a test using http://localhost:3000/?embed=true which seems to work fine for checking the padding.

@lukasmasuch
Copy link
Collaborator Author

@kmcgrady I added an e2e test. It only checks for the correct padding, but I think this is probably sufficient in this case.

@lukasmasuch lukasmasuch merged commit 2d2190e into develop Jul 10, 2023
tconkling added a commit to tconkling/streamlit that referenced this pull request Jul 12, 2023
* develop:
  Feature: st.toast (streamlit#6783)
  Bump semver from 5.7.1 to 5.7.2 in /frontend (streamlit#6982)
  Add host communication e2e tests  (streamlit#6806)
  Re-add homepage to package.json (streamlit#6987)
  Remove unnecessary code and Add rm commands to make clean (streamlit#6980)
  Allow setting placeholder for st.selectbox (streamlit#6913)
  Allow setting placeholder for st.multiselect (streamlit#6901)
  Also use bottom padding in embedded mode for chat input (streamlit#6979)
  Feature/st lib (streamlit#6692)
  Remove unused import (streamlit#6977)
  Release 1.24.1 (streamlit#6965)
  Update st.audio/st.video docstrings (streamlit#6964)
  Slightly simplify bug report template (streamlit#6972)
  Fix baseweb warnings by using longhand properties (streamlit#6976)
@vdonato vdonato deleted the fix/chat-input-bottom-padding branch November 1, 2023 23:57
asmeralt pushed a commit to asmeralt/streamlit that referenced this pull request Sep 29, 2025
* Also use bottom padding in embedded mode

* Change bottom embed padding back to const

* Add e2e test to check css

* Add license header

* Use px instead of rem
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.

3 participants