-
Notifications
You must be signed in to change notification settings - Fork 4
fix: correct schema sidebar click offset bug #5
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
TreeState's click_at method expects absolute screen coordinates, not relative ones. The tree widget stores absolute y positions during render, so we now pass mouse coordinates directly instead of converting to relative coordinates.
WalkthroughThe PR refactors sidebar click handling to use absolute screen coordinates instead of relative coordinates, and updates the corresponding parameter naming and documentation. An import list is also reformatted for consistency in app.rs without functional changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/tsql/src/ui/sidebar.rs (1)
419-432: Coordinate space is correct; border click filtering is optional.The use of absolute coordinates
Position::new(x, y)is appropriate—TreeState::click_at()expects absolute terminal/frame coordinates, which aligns with your implementation. If you want to improve UX by preventing accidental selection changes when clicking on the schema block border or title row, you can optionally add a check to ignore clicks on or above the schema area's top boundary:fn handle_schema_click( &mut self, x: u16, y: u16, _schema_area: Rect, ) -> (Option<SidebarAction>, Option<SidebarSection>) { + // Optional: ignore clicks on the border/title row(s). + if let Some(area) = self.schema_area { + if y <= area.y { + return (None, Some(SidebarSection::Schema)); + } + } + // TreeState's click_at expects absolute screen coordinates, not relative ones. // The tree widget stores absolute y positions in last_rendered_identifiers // during render, so we pass the mouse coordinates directly. use ratatui::layout::Position; self.schema_state.click_at(Position::new(x, y)); (None, Some(SidebarSection::Schema)) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
crates/tsql/src/app/app.rs(1 hunks)crates/tsql/src/ui/sidebar.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Runcargo fmt --allto format the code before committing changes
Runcargo clippy --all --all-targets -- -D warningsto check for lints and fix them before pushing changes
Files:
crates/tsql/src/ui/sidebar.rscrates/tsql/src/app/app.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test (windows-latest)
🔇 Additional comments (1)
crates/tsql/src/app/app.rs (1)
29-38: Import-list reflow only — OK.
No functional delta here; just ensure the branch is formatted/linted per repo guidelines (cargo fmt --all,cargo clippy --all --all-targets -- -D warnings).
Summary
handle_schema_clickwas converting absolute screen coordinates to relative coordinates before passing toTreeState::click_at(), but the tree widget expects absolute coordinatesTest plan
Summary by CodeRabbit
Bug Fixes
Style
✏️ Tip: You can customize this high-level summary in your review settings.