Skip to content

Conversation

@tvst
Copy link
Contributor

@tvst tvst commented Aug 26, 2019

The Sidebar PR accidentally reduced the vertical spacing of Streamlit elements. This fixes that with a one-line CSS change, and then does some small refactors for Block-related readability.

@tvst tvst requested a review from kantuni August 26, 2019 06:08
@tvst tvst self-assigned this Aug 26, 2019
type SimpleElement = ImmutableMap<string, any>
type Element = SimpleElement | BlockElement
interface BlockElement extends List<Element> { }
type StElement = SimpleElement | BlockElement
Copy link
Contributor Author

@tvst tvst Aug 26, 2019

Choose a reason for hiding this comment

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

The name Element is confusing, since it is a type that already exists in JS. So I renamed this type to make it clear we're not talking about normal DOM elements.

class Block extends PureComponent<Props> {
private renderElements = (width: number): ReactNode[] => {
const elementsToRender = this.handleEmptyElements()
const elementsToRender = this.getElements()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clearer function name.

const elementsToRender = this.handleEmptyElements()
const elementsToRender = this.getElements()

// Transform Streamlit elements into ReactNodes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I broke this code into functions. No logic change.

}

private isStaleElement(element: SimpleElement): boolean {
private isElementStale(element: SimpleElement): boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed for clarity.

.element-container {
display: block;
display: flex;
flex-direction: column;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the vertical spacing fix

const signatureHtml = <span className="doc-signature">{signature}</span>
const moduleHtml = <span className="doc-module" key="module">{module}.</span>
const nameHtml = <span className="doc-name" key="name">{name}</span>
const signatureHtml = <span className="doc-signature" key="signature">{signature}</span>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Address React warnings in the JS console.

@tvst tvst merged commit a62f621 into streamlit:develop Aug 26, 2019
@tvst tvst deleted the sidebar-cleanup branch August 26, 2019 18:51
tconkling added a commit to tconkling/streamlit that referenced this pull request Aug 27, 2019
* develop:
  st.map() using deck_gl (streamlit#14)
  Adding support for if and for to magic (streamlit#12)
  Fix vertical spacing in Streamlit reports (streamlit#7)
  Fix streamlit#6: report should loads element by element (was broken since Sidebar PR) (streamlit#9)
sfc-gh-nbellante added a commit that referenced this pull request Oct 27, 2025
Removed customizable strings from ChatComposer to match ChatAudioRecorder.
This pattern was over-engineering - no i18n system exists yet and it adds
unnecessary complexity. Now uses hard-coded aria-labels directly.

Also restored requestAnimationFrame in focusInput after tests proved it's
necessary. RAF ensures focus happens after click events fully process,
preventing race conditions when transitioning focus from buttons to input.

Resolves PR #12834 comment #7
Addresses PR #12834 comment #4
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