[fix] horizontal alignment of st.image in vertical containers#12495
[fix] horizontal alignment of st.image in vertical containers#12495sfc-gh-lwilby merged 4 commits intodevelopfrom
Conversation
🎉 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) |
✅ PR preview is ready!
|
| with st.container( | ||
| horizontal_alignment="center", key="container-horizontal-centered-elements" | ||
| ): | ||
| img: npt.NDArray[np.int_] = np.repeat(0, 10000).reshape(100, 100) |
There was a problem hiding this comment.
The type annotation npt.NDArray[np.int_] violates Python Guide typing requirements. Use typing_extensions for back-porting newer typing features and add from __future__ import annotations. Additionally, np.int_ is deprecated in newer numpy versions and should be replaced with specific integer types like np.int64.
Spotted by Diamond (based on custom rule: Python Guide)
Is this helpful? React 👍 or 👎 to let us know.
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the horizontal alignment of st.image elements within vertical containers by adjusting how the image container width is handled in the frontend layout system.
- Removes
imgsfrom the width stretch override list and adds specific handling for image elements - Adds specific width handling for
arrowDataFrameelements withuseContentconfiguration - Adds E2E test coverage for centered elements in containers including images and dataframes
Reviewed Changes
Copilot reviewed 3 out of 6 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
frontend/lib/src/components/core/Block/StyledElementContainerLayoutWrapper.tsx |
Removes imgs and arrowDataFrame from width stretch override, adds specific width handling logic for both element types |
e2e_playwright/st_layouts_container_alignment_test.py |
Adds test case for container with horizontally centered elements |
e2e_playwright/st_layouts_container_alignment.py |
Adds test container with centered image, dataframe, and button elements |
Describe your changes
GitHub Issue Link (if applicable)
fixes #12435
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.