-
Notifications
You must be signed in to change notification settings - Fork 4k
Add path tooltip on st.json value click
#13113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ 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. |
✅ PR preview is ready!
|
📈 Frontend coverage change detectedThe frontend unit test (vitest) coverage has increased by 0.0300%
🎉 Great job on improving test coverage! |
…p-on-json-val-click
|
@cursor review |
st.json value click
There was a problem hiding this 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 adds a tooltip feature that displays the JSON path when users click on values in st.json. The tooltip includes a copy-to-clipboard button and uses JSONPath-style notation (e.g., root.nested.value, items[0]).
Key Changes:
- Created a custom React hook (
useJsonTooltip) to manage tooltip state and format JSON paths - Added a new tooltip component (
JsonPathTooltip) with copy functionality - Integrated the tooltip into the existing JSON element with click handling
Reviewed changes
Copilot reviewed 6 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
frontend/lib/src/components/elements/Json/useJsonTooltip.ts |
Custom hook managing tooltip state, mouse position tracking, and JSON path formatting |
frontend/lib/src/components/elements/Json/useJsonTooltip.test.ts |
Comprehensive unit tests for the hook covering path formatting and state management |
frontend/lib/src/components/elements/Json/JsonPathTooltip.tsx |
Tooltip component using BaseWeb Popover with copy-to-clipboard functionality |
frontend/lib/src/components/elements/Json/styled-components.ts |
Styled components for the tooltip, path text, and copy button |
frontend/lib/src/components/elements/Json/Json.tsx |
Integration of tooltip functionality into the JSON element |
e2e_playwright/st_json_test.py |
E2E test verifying tooltip appears and displays correctly on click |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
SummaryThis PR adds a new feature to Key changes:
Code QualityStrengths:
Minor observations:
Test CoverageUnit Tests:
Potential improvements (non-blocking):
E2E Tests:
Backwards CompatibilityNo breaking changes identified:
Behavioral consideration:
Security & RiskNo security concerns:
Low regression risk:
RecommendationsNo blocking issues found. The following are minor suggestions for future consideration:
VerdictAPPROVED: This PR implements a useful feature with clean, well-tested code that follows Streamlit's coding conventions. The changes are additive with no breaking changes, comprehensive test coverage including E2E visual tests, and proper cleanup of event listeners. Ready for merge. This is an automated AI review. Please verify the feedback and use your judgment. |
…p-on-json-val-click
| }} | ||
| isOpen={isOpen} | ||
| > | ||
| <div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: This should be a styled-component.
Describe your changes
Shows a tooltip with the path information if a json value gets clicked:
Note: This is slightly hacky since the underlying library doesn't provide a lot of clean ways to implement click or hover events. We might eventually also migrate to another json tree library with better support for this type of customization.
GitHub Issue Link (if applicable)
st.json#13057Testing 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.