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

8172 update the right drawer action menu to open with command o #8375

Conversation

bosiraphael
Copy link
Contributor

Closes #8172

  • Added a shortcut property to the button component
  • Displays the actions inside a dropdown
  • The dropdown is toggled either by clicking on the button or with the command + O shortcut
Enregistrement.de.l.ecran.2024-11-06.a.17.33.47.mov

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 updates the right drawer action menu to implement a dropdown-based system with keyboard shortcut support.

  • Added new RightDrawerActionMenuDropdown component with ⌘O shortcut support via useScopedHotkeys hook
  • Enhanced Button component in twenty-ui to display keyboard shortcuts with styled separator
  • Removed RecordShowActionMenuBarEntry and RecordShowRightDrawerActionMenuBar in favor of dropdown implementation
  • Added utility function getRightDrawerActionMenuDropdownIdFromActionMenuId for consistent dropdown ID generation
  • Modified RichTextEditor hotkey configuration to prevent shortcut conflicts

11 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings | Greptile

<ActionMenuContext.Provider
value={{
isInRightDrawer: true,
onActionExecutedCallback: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Empty callback could lead to missed state updates if actions need to trigger UI changes

const theme = useTheme();

useScopedHotkeys(
[Key.Escape, 'ctrl+o,meta+o'],
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Potential conflict between Escape and Ctrl+O/Cmd+O being in same hotkey array - these should be separate useScopedHotkeys calls

Comment on lines +69 to +72
{actionMenuEntries.map((item, index) => (
<MenuItem
key={index}
LeftIcon={item.Icon}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Using array index as key can cause issues with React reconciliation if items are reordered. Consider using a stable unique identifier from item

Comment on lines +73 to +80
onClick={() => {
closeDropdown(
getRightDrawerActionMenuDropdownIdFromActionMenuId(
actionMenuId,
),
);
item.onClick?.();
}}
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 handling errors that may occur during item.onClick() execution

clickableComponent={<Button title="Actions" shortcut="⌘O" />}
dropdownPlacement="top-end"
dropdownOffset={{
y: parseInt(theme.spacing(2)),
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: parseInt without radix parameter and potential NaN result if theme.spacing(2) returns non-numeric value

@@ -113,12 +113,21 @@ export const WithButtonClicks: Story = {
play: async ({ canvasElement }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Test should verify that the dropdown closes after each action. Currently it manually reopens the dropdown but doesn't verify the closing behavior.

Comment on lines 352 to +356
RightDrawerHotkeyScope.RightDrawer,
[],
{
preventDefault: false,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The empty dependencies array could cause stale closure issues if any values from the closure are used in the callback. Consider adding any dependencies used in the callback function.

Comment on lines 367 to 372
const StyledSeparator = styled.div<{ size: 'sm' | 'md' }>`
background: ${({ theme }) => theme.border.color.light};
height: ${({ theme, size }) => theme.spacing(size === 'sm' ? 4 : 8)};
margin: 0 ${({ theme }) => theme.spacing(1)};
width: 1px;
`;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: StyledSeparator size prop accepts 'md' but it's never used in the component

};

export const ShortcutCatalog: CatalogStory<Story, typeof Button> = {
args: { title: 'Actions', shortcut: '⌘O' },
Copy link
Contributor

Choose a reason for hiding this comment

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

style: ⌘O is Mac-specific. Consider using a cross-platform shortcut display like 'Cmd/Ctrl+O'

decorators: [CatalogDecorator],
};

export const ShortcutCatalog: CatalogStory<Story, typeof Button> = {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: ShortcutCatalog duplicates state handling code from PositionCatalog. Consider extracting shared logic into a utility function

@bosiraphael bosiraphael merged commit e8bf81d into main Nov 8, 2024
18 checks passed
@bosiraphael bosiraphael deleted the 8172-update-the-right-drawer-action-menu-to-open-with-command-o branch November 8, 2024 16:08
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.

Update the right drawer action menu to open with command O
2 participants