[feature] Always show the dataframe column visibility menu#14336
[feature] Always show the dataframe column visibility menu#14336lukasmasuch merged 6 commits intodevelopfrom
Conversation
The column visibility icon (eye icon) in the dataframe toolbar was hidden when all columns were visible. This change makes it always visible so users can easily access the column visibility menu regardless of current column state. - Closes #14320 Co-Authored-By: Claude Opus 4.6 <[email protected]>
✅ PR preview is ready!
|
There was a problem hiding this comment.
Pull request overview
Fixes the DataFrame toolbar’s column-visibility (eye) icon so it’s available whenever the table has columns, even when no columns are currently hidden (addressing #14320).
Changes:
- Always render the column visibility menu trigger when the table is non-empty and
allColumns.length > 0. - Update the related unit tests to account for the additional toolbar action and to assert the visibility action exists when all columns are shown.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| frontend/lib/src/components/widgets/DataFrame/DataFrame.tsx | Adjusts the render condition so the column visibility menu/button is shown whenever columns exist (not only when some are hidden). |
| frontend/lib/src/components/widgets/DataFrame/DataFrame.test.tsx | Updates toolbar expectations and adds a test to ensure the “Show/hide columns” action is present when all columns are visible. |
Comments suppressed due to low confidence (1)
frontend/lib/src/components/widgets/DataFrame/DataFrame.tsx:631
- Use strict equality here (
===) instead of==for consistency with the rest of the file and to avoid unintended coercion.
useEffect(() => {
if (allColumns.length == columns.length) {
setShowColumnVisibilityMenu(false)
}
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
## Describe your changes Automated snapshot updates for #14336 created via the snapshot autofix CI workflow. This workflow was triggered by adding the `update-snapshots` label to a PR after Playwright E2E tests failed with snapshot mismatches. **Updated snapshots:** 15 file(s)⚠️ **Please review the snapshot changes carefully** - they could mask visual bugs if accepted blindly. This PR targets a feature branch and can be merged without review approval. Co-authored-by: Streamlit Bot <[email protected]>
Add notes to column_order and column_config parameters in st.dataframe and st.data_editor to clarify that columns hidden via these options can still be shown by the user via the column visibility menu in the table toolbar. Sensitive data should be removed from the dataframe before passing it to these functions. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Remove the useEffect that automatically closed the column visibility menu when all columns became visible. This was jarring UX that prevented users from quickly toggling columns (e.g., clicking "Select all" then immediately unchecking one column). Co-Authored-By: Claude Opus 4.6 <[email protected]>
SummaryThis PR makes the dataframe column visibility menu (eye icon) always visible in the toolbar, instead of only showing it when some columns are already hidden. Previously, users had no way to discover the column visibility feature until they first hid a column via the column context menu. The PR also removes an unnecessary Key changes:
Code QualityAll three reviewers agreed the code is clean, focused, and well-scoped:
Test CoverageAll reviewers agreed coverage is adequate:
Backwards CompatibilityUnanimous agreement — no breaking changes:
Security & RiskNo security concerns identified (unanimous). The change is UI-only and doesn't touch authentication, WebSocket handling, file operations, or server-side logic. The added docstring notes improve security awareness by explicitly warning developers not to pass sensitive data to the frontend even if columns are configured as "hidden." External test recommendation
AccessibilityNo accessibility regressions identified (unanimous). The column visibility button retains its Reviewer Agreement & DifferencesFull agreement across all three reviewers on:
Minor style point (two of three reviewers):
Resolution: The Recommendations
VerdictAPPROVED: All three reviewers unanimously approved. The change is clean, well-scoped, and low-risk. It improves discoverability of the column visibility feature, removes an unnecessary
This is a consolidated AI review by 📋 Review by `gemini-3.1-pro`SummaryThis PR updates the dataframe toolbar to always show the column visibility menu (the eye icon), regardless of whether all columns are currently visible. Previously, the icon was only shown if at least one column was hidden. It also adds important documentation notes warning users that hidden columns can still be shown by the user, advising them to remove sensitive data before passing it to the dataframe. Code QualityThe code changes are clean and straightforward:
Test Coverage
Backwards CompatibilityThere are no breaking API changes. The UI will now show an additional icon in the dataframe toolbar by default. The documentation updates correctly highlight a pre-existing behavior (that hidden columns can be unhidden by the user via the UI) which might surprise some developers who were using Security & RiskNo new security risks are introduced. In fact, the documentation updates improve security awareness by explicitly warning developers not to pass sensitive data to the frontend, even if it is configured to be "hidden". External test recommendationNo. Triggered categories: None. The changes are limited to frontend UI rendering logic (always showing a button) and Python docstring updates. There are no modifications to routing, authentication, websockets, or cross-origin behavior. Confidence is high. AccessibilityThe column visibility button remains accessible, utilizing the existing "Show/hide columns" aria-label (as verified by the updated unit tests). RecommendationsThe implementation looks solid. No further changes are required. VerdictAPPROVED: The changes successfully implement the feature, are well-tested, and include excellent documentation updates regarding data visibility. This is an automated AI review by 📋 Review by `gpt-5.3-codex-high`SummaryThis PR makes the dataframe/data editor column visibility menu button always available when the table has columns, instead of only showing it after columns become hidden. It also updates public Python docs to explicitly clarify that hidden/omitted columns can still be revealed in the UI, and refreshes affected Playwright snapshots. Code QualityThe implementation is small, focused, and aligns with existing frontend patterns:
No maintainability or correctness issues were identified in the changed logic. Test CoverageCoverage is good for the scope of this change:
Given the narrow UI condition change, this is adequate. Backwards CompatibilityNo API-level breaking changes were introduced.
Security & RiskNo security-sensitive infrastructure paths were modified (no routing/auth/session/cookie/CORS/WebSocket/server endpoint changes).
Regression risk is low and primarily visual/UX. External test recommendation
AccessibilityNo accessibility regressions identified.
Recommendations
VerdictAPPROVED: The change is focused, low-risk, documented, and sufficiently covered for the scope. This is an automated AI review by 📋 Review by `opus-4.6-thinking`SummaryThis PR makes the dataframe column visibility menu (eye icon) always visible in the toolbar, instead of only showing it when some columns are hidden. Previously, users couldn't discover the column visibility feature until they first hid a column via the column context menu. The change also removes a Key changes:
Code QualityThe code is clean and well-scoped:
Minor note in the test file at it("should show column visibility button when all columns are visible", () => {
render(<DataFrame {...props} />)
// The column visibility button should be present even when all columns are shown
// (it appears when the toolbar is shown via hover)
expect(screen.getByLabelText("Show/hide columns")).toBeInTheDocument()
})Per Test Coverage
Backwards CompatibilityThis change is fully backwards compatible:
Security & Risk
External test recommendation
Accessibility
Recommendations
VerdictAPPROVED: Clean, well-scoped change that improves discoverability of the column visibility feature, removes an unnecessary This is an automated AI review by |
The column visibility icon is now always shown in the dataframe toolbar, so tests that check button counts need to expect 3 buttons (search, download, column visibility) instead of 2. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Describe your changes
The column visibility icon (eye icon) in the dataframe toolbar was hidden when all columns were visible. This change makes it always visible so users can easily access the column visibility menu regardless of current column state.
allColumns.length > columns.lengthtoallColumns.length > 0so the icon appears when there are any columns, not only when some are hiddenGitHub Issue Link (if applicable)
pd.dataframeeye icon in toolbar not always visible #14320st.column_config.Columnvisibility restrictions in the UI #10649Testing Plan
test_column_hiding_via_visibility_menupassesContribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.