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

Skip to content

Conversation

@sfc-gh-lwilby
Copy link
Collaborator

@sfc-gh-lwilby sfc-gh-lwilby commented Oct 3, 2025

Describe your changes

Fixes horizontal alignment for DataFrames when using width="content" in containers with horizontal_alignment set.

Changes Made:

  • Removed full-width on StyledElementContainer: Previously, DataFrames with width="content" were wrapped in a full-width container because the resize logic needed it to calculate available width. This wrapper prevented proper horizontal alignment.
  • Disabled resize logic for content width: When width="content" is used, resize handles are now disabled (similar to horizontal layouts) to prevent resizing beyond the parent container.
  • Updated E2E tests: Added test case for DataFrame horizontal alignment with width="content".

Key Implementation:

The resize disable logic now checks both horizontal layout context AND content width setting. This allows DataFrames with content width to flow naturally and respect container alignment while preventing unwanted resizing.

GitHub Issue Link (if applicable)

N/A

Testing Plan

  • E2E Tests - Updated st_layouts_container_alignment.py to test DataFrame with width="content" in centered container
  • Manual testing completed - Verified DataFrames properly center align with content width
  • Verified resize handles are properly disabled when using content width

Screenshots/Demos:

E2E test snapshots will show proper horizontal alignment of DataFrames with width="content" in centered containers.

Screenshot 2025-10-03 at 4 43 30 PM

Additional Notes:

This fix aligns DataFrame behavior with other elements that support width="content" and properly respect container horizontal alignment.


Contribution License Agreement

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

@sfc-gh-lwilby sfc-gh-lwilby 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 Oct 3, 2025
@snyk-io
Copy link
Contributor

snyk-io bot commented Oct 3, 2025

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

Status Scanner Critical High Medium Low Total (0)
Licenses 0 0 0 0 0 issues
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-12682/streamlit-1.50.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-12682.streamlit.app (☁️ Deploy here if not accessible)

@sfc-gh-lwilby
Copy link
Collaborator Author

This change affects the resizing feature for width="content" dataframes. Defect is tracked here #12683

@sfc-gh-lwilby sfc-gh-lwilby changed the title Fix DataFrame content width horizontal alignment [fix] DataFrame content width horizontal alignment Oct 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2025

📉 Frontend coverage change detected

The frontend unit test (vitest) coverage has decreased by 0.0000%

  • Current PR: 85.8800% (48407 lines, 6832 missed)
  • Latest develop: 85.8800% (48394 lines, 6830 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

@sfc-gh-lwilby sfc-gh-lwilby changed the title [fix] DataFrame content width horizontal alignment [WIP][fix] DataFrame content width horizontal alignment Oct 3, 2025
@sfc-gh-lwilby sfc-gh-lwilby force-pushed the fix/dataframe-content-width-horizontal-alignment branch from 717a75c to b8f7769 Compare October 14, 2025 13:15
@lukasmasuch lukasmasuch requested a review from Copilot October 15, 2025 07:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes horizontal alignment for DataFrames when using width="content" in containers with horizontal alignment set. DataFrames with content width were previously wrapped in a full-width container that prevented proper horizontal alignment.

Key changes:

  • Disabled resize functionality for DataFrames with width="content" to allow natural flow and respect container alignment
  • Removed forced full-width styling from element containers for DataFrames and charts with content width
  • Updated E2E tests to verify proper horizontal alignment behavior

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/lib/src/components/widgets/DataFrame/styled-components.ts Renamed prop from isInHorizontalLayout to disableResize and updated styling logic
frontend/lib/src/components/widgets/DataFrame/ReadOnlyGrid.tsx Added width prop to support passing width configuration to DataFrame component
frontend/lib/src/components/widgets/DataFrame/DataFrame.tsx Updated resize disable logic to check both horizontal layout and content width settings
frontend/lib/src/components/elements/ArrowVegaLiteChart/ArrowVegaLiteChart.tsx Passed width configuration to ReadOnlyGrid for charts
frontend/lib/src/components/core/Block/StyledElementContainerLayoutWrapper.tsx Removed forced full-width styling for DataFrames and charts with content width
e2e_playwright/st_layouts_container_alignment.py Updated test to include DataFrame with content width in centered container

@sfc-gh-lwilby sfc-gh-lwilby force-pushed the fix/dataframe-content-width-horizontal-alignment branch from 3b50f4b to d403970 Compare October 20, 2025 16:41
@sfc-gh-lwilby sfc-gh-lwilby marked this pull request as ready for review October 23, 2025 13:58
@sfc-gh-lwilby sfc-gh-lwilby changed the title [WIP][fix] DataFrame content width horizontal alignment [fix] DataFrame content width horizontal alignment Oct 23, 2025
@sfc-gh-lwilby sfc-gh-lwilby merged commit cdd601a into develop Oct 24, 2025
38 checks passed
@sfc-gh-lwilby sfc-gh-lwilby deleted the fix/dataframe-content-width-horizontal-alignment branch October 24, 2025 05:50
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