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

2727-fix(front): CommandMenu and KeyboardMenu invoke handled #2783

Merged
merged 3 commits into from
Dec 1, 2023

Conversation

Kanav-Arora
Copy link
Contributor

Closes #2727

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.

Thank you @Kanav-Arora :)

@@ -89,14 +91,20 @@ export const CommandMenu = () => {
const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState);
const [search, setSearch] = useState('');
const commandMenuCommands = useRecoilValue(commandMenuCommandsState);

const { closeKeyboardShortcutMenu } = useKeyboardShortcutMenu();
const isKeyboardShortcutMenuOpened = useRecoilValue(
Copy link
Member

Choose a reason for hiding this comment

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

@Kanav-Arora We don't want to use the states directly outside of its component. This allow us to provide a nice API for our components.

This is also to optimize for re-renders. Here it's not too bad but, every time isKeyboardShortcutMenuOpened changed, the whole CommandMenu will re-render. That's why, while designing Keyboard shortcut menu API (aka useKeyboardShortcutMenu), we really need to ask ourselve what we want to expose in order to not push our component users to not trigger re-renders.

In this particular case, I think we don't ant to listen at this isKeyboardShortcutMenuOpenedState at all, we want to close the keyboardShortCutMenu in any case, worst case nothing happens

@@ -20,9 +22,14 @@ export const KeyboardShortcutMenu = () => {
const isKeyboardShortcutMenuOpened = useRecoilValue(
isKeyboardShortcutMenuOpenedState,
);
const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState);
Copy link
Member

Choose a reason for hiding this comment

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

same here!

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.

@Kanav-Arora I'm merging it with changes (see comments) because we are planning to move many files over the week-end, it would be too bad that your PR would have many conflicts.
I'm also including an unrelated fix that I found while working on your PR

Thank you!

@charlesBochet charlesBochet merged commit 31f2958 into twentyhq:main Dec 1, 2023
4 of 6 checks passed
@charlesBochet charlesBochet mentioned this pull request Dec 8, 2023
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.

Invoking Command Menu should close Keyboard Menu
2 participants