Feat: Automatically hide row indices in st.dataframe when row selection is active#12448
Merged
lukasmasuch merged 5 commits intostreamlit:developfrom Sep 19, 2025
Merged
Conversation
Contributor
🎉 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) |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements automatic hiding of row indices in st.dataframe when row selection is active, improving the user experience by reducing visual clutter while still allowing manual override via hide_index=False.
Key Changes
- Automatically hides the index column when row selection modes ("single-row" or "multi-row") are active
- Preserves user control by allowing
hide_index=Falseto explicitly show the index - Implementation follows the existing column configuration pattern
Comments suppressed due to low confidence (1)
lib/streamlit/elements/arrow.py:715
- The automatic hiding logic should only apply when
hide_indexis not explicitly set by the user. Currently, this code will hide the index even whenhide_index=Falseis explicitly passed, and then the subsequent check will override it. The condition should beif is_selection_activated and selection_mode in [\"multi-row\", \"single-row\"] and hide_index is None:to respect explicit user preferences.
if is_selection_activated and selection_mode in ["multi-row", "single-row"]:
update_column_config(
column_config_mapping, INDEX_IDENTIFIER, {"hidden": True}
)
if hide_index is not None:
update_column_config(
column_config_mapping, INDEX_IDENTIFIER, {"hidden": hide_index}
)
Collaborator
|
Behavior looks good! Could maybe add a sentence on this behavior to the docstring of |
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
lukasmasuch
approved these changes
Sep 19, 2025
Collaborator
lukasmasuch
left a comment
There was a problem hiding this comment.
LGTM 👍 I added a couple of tweaks and tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Implements the suggestion that range indices in
st.dataframeshould be hidden automatically when row selections are active and hide_index is not set or is not false.Allows users to enable the index column via
hide_index=False.Image render link provided in the original issue: #12237 (comment)
GitHub Issue Link (if applicable)
Implementation of the suggestion listed here: #12237
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.