-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix action menu dropdown #8368
Fix action menu dropdown #8368
Conversation
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.
PR Summary
This PR improves action menu dropdown behavior and ID management across the application, focusing on proper click-outside handling and consistent component ID generation.
- Introduces new utility functions (
getActionBarIdFromActionMenuId
,getActionMenuDropdownIdFromActionMenuId
,getActionMenuIdFromRecordIndexId
) in/packages/twenty-front/src/modules/action-menu/utils/
to standardize component ID generation - Replaces
useListenClickOutside
withuseListenClickOutsideV2
in/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx
for better click-outside event handling - Moves state extraction outside callbacks in hooks like
useRecordBoardSelection
anduseTriggerActionMenuDropdown
for improved performance - Adds proper test coverage for new utility functions in
/packages/twenty-front/src/modules/action-menu/utils/__tests__/
- Uses
useAvailableComponentInstanceIdOrThrow
consistently for component instance context validation
21 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -1,26 +1,32 @@ | |||
import { getActionBarIdFromActionMenuId } from '@/action-menu/utils/getActionBarIdFromActionMenuId'; | |||
import { getActionMenuDropdownIdFromActionMenuId } from '@/action-menu/utils/getActionMenuDropdownIdFromActionMenuId'; | |||
import { useBottomBar } from '@/ui/layout/bottom-bar/hooks/useBottomBar'; | |||
import { useDropdownV2 } from '@/ui/layout/dropdown/hooks/useDropdownV2'; | |||
|
|||
export const useActionMenu = (actionMenuId: string) => { |
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.
style: Consider adding type validation for actionMenuId to ensure it's not empty/undefined
export const getActionMenuIdFromRecordIndexId = (recordIndexId: string) => { | ||
return `action-menu-record-index-${recordIndexId}`; |
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.
style: Consider adding input validation to ensure recordIndexId is not empty/undefined
const isActionBarOpenState = isBottomBarOpenedComponentState.atomFamily({ | ||
instanceId: getActionBarIdFromActionMenuId(actionMenuInstanceId), | ||
}); |
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.
logic: isBottomBarOpenedComponentState.atomFamily is called on every render. Move this outside the component or memoize it.
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.
Nice one :)
Fix action menu dropdown not closing when clicking outside the table or board and introduce helper functions to get the action menu component ids.