kmedri
February 26, 2023, 5:21am
1
The picture below shows a st.selectbox() on the left with the icon positioned nicely to the right and inline with the label.
On the right is the st.metric() widget with the help icon positioned below the label.
The hack I used:
.css-1whk732 {
-webkit-box-pack: end;
justify-content: flex-end;
flex: 1 1 0%;
}
Here is the result, not perfect but much better.
Is the alignment set below the label normal for st.metric(), or have I done something wrong?
The default alignment puts the question mark symbol on the right-hand side of the label. Youβre likely seeing the question mark symbol below the label due to the size of the column/this is probably a bug. If you take away the columns or reduce to two columns, does the positioning of the question mark symbol change?
kmedri
March 1, 2023, 12:25am
3
It looks like it may be a bug. If we look at the st.selectbox()
it is inside a label
with a class set with display: flex
as follows:
the tooltip then has a class set with display: flex
and flex: 1 1 0%
as follows:
This positions the help icon inline and to the right of the label.
st.metric()
label has another div
nested inside that sets display: block
and overides the display: flex
:
Hi @kmedri
You and @Caroline were right! It was a bug We identified the regression in v1.18.0:
opened 08:48AM - 10 Feb 23 UTC
closed 12:45AM - 16 Feb 23 UTC
type:bug
status:confirmed
priority:P2
feature:st.metric
### Checklist
- [X] I have searched the [existing issues](https://github.com/β¦ streamlit/streamlit/issues) for similar issues.
- [X] I added a very descriptive title to this issue.
- [X] I have provided sufficient information below to help reproduce this issue.
### Summary
[Reported](https://discuss.streamlit.io/t/version-1-18-0/37501/3?u=snehankekre) by @marduk2 on our forum. The `help` tooltip for `st.metric` has changed positions in v1.18.0 and appears under the metric label instead of to its right.
### Reproducible Code Example
```Python
import streamlit as st
st.title("'Help' tooltips in st.metric render in a weird position")
st.metric(
label="Example metric",
help="Something doesn't feel right...",
value=150.59,
delta="Very high",
)
```
### Steps To Reproduce
1. Run the app
### Expected Behavior

### Current Behavior

### Is this a regression?
- [X] Yes, this used to work in a previous version.
### Debug info
- Streamlit version: 1.18.0
- Python version: 3.9
- Operating System: macOS
- Browser: Chrome
- Virtual environment: NA
### Additional Information
_No response_
### Are you willing to submit a PR?
- [ ] Yes, I am willing to submit a PR!
and fixed it:
streamlit:develop
β streamlit:fix-st-metric-regression
opened 07:49PM - 14 Feb 23 UTC
## π Context
This PR fixes a regression in reported by @snehankekre, where th⦠e `help` tooltip in `st.metric` would show up in the wrong place.
- What kind of change does this PR introduce?
- [x] Bugfix
- [ ] Feature
- [ ] Refactoring
- [ ] Other, please describe:
## π§ Description of Changes
- Added `display: flex;` to `StyleTruncateText` so we can place the `(?)` icon next to the label;
- Added `overflow: hidden;` to the `StyledStreamlitMarkdown` label container;
- Added `overflow: hidden;` and `text-overflow: ellipsis;` to the actual `<p>` tag inside the label container.
- [ ] This is a breaking API change
- [x] This is a visible (user-facing) change
**Revised:**


**Current:**

## π§ͺ Testing Done
- [x] Screenshots included
- [ ] Added/Updated unit tests
- [x] Added/Updated e2e tests
## π References
- **Issue**: Closes #6093
---
**Contribution License Agreement**
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
The label in st.metric
should appear in the expected position if you upgrade to streamlit==1.19.0
, as detailed in the 1.19.0 changelog .
1 Like
kmedri
March 6, 2023, 12:50pm
5
Thank you for the quick fix, very impressed.