-
Notifications
You must be signed in to change notification settings - Fork 24
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
Update Cursor Right Away When Bounding Box Is Hovered #8253
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe pull request introduces several changes to enhance keyboard and mouse interaction within the application. Key modifications include the addition of a Changes
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
frontend/javascripts/oxalis/controller/viewmodes/plane_controller.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/controller/viewmodes/plane_controller.tsx
Outdated
Show resolved
Hide resolved
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
🧹 Outside diff range and nitpick comments (1)
frontend/javascripts/oxalis/controller/viewmodes/plane_controller.tsx (1)
183-192
: Consider adding type safety for mousePosition array access.While the implementation is correct, consider adding type safety for the mousePosition array access to prevent potential runtime errors.
- { x: mousePosition[0], y: mousePosition[1] }, + { x: mousePosition[0] ?? 0, y: mousePosition[1] ?? 0 },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
frontend/javascripts/libs/input.ts
(4 hunks)frontend/javascripts/oxalis/controller/combinations/bounding_box_handlers.ts
(1 hunks)frontend/javascripts/oxalis/controller/viewmodes/plane_controller.tsx
(7 hunks)
🔇 Additional comments (5)
frontend/javascripts/oxalis/controller/combinations/bounding_box_handlers.ts (1)
268-268
: LGTM: Event type expansion enhances keyboard interaction support.
The function signature change to accept both MouseEvent
and KeyboardEvent
is well-implemented and necessary for supporting cursor updates on keyboard events.
frontend/javascripts/libs/input.ts (2)
87-87
: LGTM: Constructor enhancement properly handles key up bindings.
The addition of the optional keyUpBindings
parameter and its initialization is well-implemented, maintaining backward compatibility while adding new functionality.
Also applies to: 113-114
Line range hint 146-181
: LGTM: Attach method properly handles both key down and up events.
The updated method signature and implementation correctly supports both key down and up events while maintaining existing functionality.
frontend/javascripts/oxalis/controller/viewmodes/plane_controller.tsx (2)
208-210
: LGTM: Clean implementation of key handler creation.
The function is simple, focused, and correctly implements the key handler creation.
524-528
: LGTM: Proper integration of meta and ctrl key handlers.
The keyboard controls are well-structured and correctly handle both key down and up events for meta and ctrl keys.
Also applies to: 551-557
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
🧹 Outside diff range and nitpick comments (1)
CHANGELOG.unreleased.md (1)
21-21
: Consider documenting the known limitationWhile the changelog entry accurately describes the enhancement, it would be helpful to document the known limitation where the cursor functionality stops working after focusing on another window. This helps set correct expectations for users.
Consider updating the entry like this:
-- Within the bounding box tool, the cursor updates immediately after pressing `ctrl`, indicating that a bounding box can be moved instead of resized. [#8253](https://github.com/scalableminds/webknossos/pull/8253) +- Within the bounding box tool, the cursor updates immediately after pressing `ctrl`, indicating that a bounding box can be moved instead of resized. Note: The cursor functionality may need to be reactivated after switching window focus. [#8253](https://github.com/scalableminds/webknossos/pull/8253)
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.
Awesome works and looks good 🎉
I only find a minor nitpick :)
frontend/javascripts/oxalis/controller/viewmodes/plane_controller.tsx
Outdated
Show resolved
Hide resolved
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
🧹 Outside diff range and nitpick comments (1)
frontend/javascripts/oxalis/controller/viewmodes/plane_controller.tsx (1)
192-209
: Consider making the cursor update logic more reusableThe cursor update logic could be made more reusable by:
- Extracting the mouse position check into a separate method
- Making the event type more generic to handle both keyboard and mouse events
- static handleUpdateCursor = (event: KeyboardEvent) => { + static handleUpdateCursor = (event: KeyboardEvent | MouseEvent) => { const { viewModeData, temporaryConfiguration } = Store.getState(); - const { mousePosition } = temporaryConfiguration; - if (mousePosition == null) return; + const position = BoundingBoxKeybindings.getMousePosition(temporaryConfiguration); + if (position == null) return; highlightAndSetCursorOnHoveredBoundingBox( - { x: mousePosition[0], y: mousePosition[1] }, + position, viewModeData.plane.activeViewport, event, ); }; + static getMousePosition(temporaryConfiguration: any) { + const { mousePosition } = temporaryConfiguration; + return mousePosition ? { x: mousePosition[0], y: mousePosition[1] } : null; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
CHANGELOG.unreleased.md
(1 hunks)frontend/javascripts/oxalis/controller/viewmodes/plane_controller.tsx
(6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- CHANGELOG.unreleased.md
🔇 Additional comments (4)
frontend/javascripts/oxalis/controller/viewmodes/plane_controller.tsx (4)
69-69
: LGTM!
The import of highlightAndSetCursorOnHoveredBoundingBox
aligns with the PR objective of improving cursor behavior for bounding boxes.
187-188
: LGTM!
The addition of meta and ctrl key handlers aligns with the PR objective and follows good practices.
385-385
: LGTM!
The addition of keyUpControls parameter to InputKeyboardNoLoop is correctly implemented to support the new key-up bindings.
Also applies to: 419-419
Line range hint 524-557
: LGTM!
The keyboard controls implementation:
- Correctly handles both key down and up events
- Maintains consistency with existing patterns
- Properly integrates bounding box handlers
URL of deployed dev instance (used for testing):
Steps to test:
-> changed behaviour: before, you had to move the mouse before pressing ctrl had any effect on the cursor.
limitations
Issues:
(Please delete unneeded items, merge only when none are left open)