Closed imanjra closed 2 months ago
The recent updates enhance the AdaptiveMenu
component by integrating the useKeyDown
hook for improved keyboard event handling, allowing the menu to close with the "Escape" key. This significantly enhances user experience. Additionally, the export of the hook promotes reusability across the application, while performance optimizations through memoization reduce unnecessary re-renders. Other components, like ActionsRow
and DynamicGroupAction
, have been updated to respond better to state changes.
Files | Change Summary |
---|---|
app/packages/components/src/components/AdaptiveMenu/index.tsx |
Added useCallback for a memoized close function and integrated useKeyDown to close the menu with the "Escape" key. Updated PopoutButton to use the new close function. |
app/packages/state/src/hooks/index.ts |
Added export for the useKeyDown hook, enhancing modularity and enabling keyboard event handling in other components. |
app/packages/state/src/hooks/useKeyDown.tsx |
Introduced a custom useKeyDown hook that listens for specified key presses and invokes a handler, improving keyboard interaction capabilities in React applications. |
app/packages/core/src/components/Actions/ActionsRow.tsx |
Updated Selected component to destructure refresh from adaptiveMenuItemProps and added useEffect to call refresh when samples change, enhancing responsiveness. |
app/packages/core/src/components/Actions/DynamicGroupAction.tsx |
Integrated a refresh method from adaptiveMenuItemProps in a useEffect to trigger updates based on isProcessing state changes and improved loading indicator styling. |
app/packages/core/src/components/Grid/useEscape.ts |
Modified useEscape function to check for active escape key handlers before executing its logic, enhancing control flow and responsiveness. |
app/packages/state/src/recoil/atoms.ts |
Introduced escapeKeyHandlerIdsAtom to manage escape key handlers in Recoil state, adding to the state management functionality. |
sequenceDiagram
participant User
participant AdaptiveMenu
participant useKeyDown
User->>AdaptiveMenu: Press "Escape"
activate AdaptiveMenu
AdaptiveMenu->>useKeyDown: Check for key press
useKeyDown-->>AdaptiveMenu: Key detected
AdaptiveMenu->>AdaptiveMenu: Set open state to false
deactivate AdaptiveMenu
🐰 In a menu so adaptive and bright,
It listens for keys, both day and night.
With "Escape" it closes, oh what a delight,
A hop and a skip, everything feels right!
So here’s to the changes, both clever and neat,
A joyous little dance, let’s all take a seat! 🎉
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?
Works! I'm noticing that ESC now clears sample selection and closes the action row popout (first recording)
This will be interesting to solve. Thinking out loud, we would need a common stack for key-down handler and as you press, things are popped off the stack as they handled
Maybe out of scope, but I'm also seeing some wrapping occur in certain actions when creating dynamic groups.
Nice catch! I wonder if we should instead use the three loading dots instead of that loading text... Will check it out
@benjaminpkane fixed both wrapping of dynamic group button's loading state and escape clearing selected samples when adaptive menu's more items popout is opened.
What changes are proposed in this pull request?
Close "More Items" popover of adaptive menu when ESC is pressed
How is this patch tested? If it is not, please explain why.
Using ActionRow in split panel view
Release Notes
Is this a user-facing change that should be mentioned in the release notes?
(Details in 1-2 sentences. You can just refer to another PR with a description if this PR is part of a larger change.)
What areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit
New Features
useKeyDown
hook for managing keyboard events, improving interactive capabilities.Improvements