Skip to content
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

Merged
merged 6 commits into from
Nov 6, 2024
Merged

Fix action menu dropdown #8368

merged 6 commits into from
Nov 6, 2024

Conversation

bosiraphael
Copy link
Contributor

Fix action menu dropdown not closing when clicking outside the table or board and introduce helper functions to get the action menu component ids.

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 with useListenClickOutsideV2 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 and useTriggerActionMenuDropdown 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) => {
Copy link
Contributor

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

Comment on lines +1 to +2
export const getActionMenuIdFromRecordIndexId = (recordIndexId: string) => {
return `action-menu-record-index-${recordIndexId}`;
Copy link
Contributor

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

Comment on lines +39 to +41
const isActionBarOpenState = isBottomBarOpenedComponentState.atomFamily({
instanceId: getActionBarIdFromActionMenuId(actionMenuInstanceId),
});
Copy link
Contributor

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.

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one :)

@charlesBochet charlesBochet merged commit a6007d4 into main Nov 6, 2024
19 checks passed
@charlesBochet charlesBochet deleted the r-fix-action-menu-dropdown branch November 6, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants