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: Added keyboard functionality for esc and Ctrl + a #8282

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

harshit078
Copy link
Contributor

Description

Changes

Screen.Recording.2024-11-02.at.2.17.14.AM.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

Implemented keyboard shortcuts for record selection in the drag select component, adding support for Ctrl/Cmd + A to select all records and Escape to deselect all records.

  • Added keyboard event handler in /packages/twenty-front/src/modules/ui/utilities/drag-select/components/DragSelect.tsx for Ctrl/Cmd + A and Escape shortcuts
  • Uses queueMicrotask to handle selection changes asynchronously for better performance
  • Queries elements with data-selectable-id attribute to manage record selection state
  • Prevents default browser behavior for both keyboard shortcuts to avoid conflicts

1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 58 to 61
useEffect(() => {
document.addEventListener('keydown', handleKeyDown);
return () => document.removeEventListener('keydown', handleKeyDown);
}, [handleKeyDown]);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Global event listener could interfere with other keyboard shortcuts when multiple DragSelect components are mounted. Consider using a more scoped approach or checking if the dragSelectable element is in focus.

@Devessier Devessier self-assigned this Nov 8, 2024
@Devessier
Copy link
Contributor

Thank you a lot for your contribution, @harshit078. We tried to find a more global solution to the problem.

My implementation is still in progress. Things to finish:

  • Use scoped hotkeys for the board as well

@Devessier
Copy link
Contributor

Hello @harshit078, would you be able to continue working on this feature? I will try to do it myself if not. Thank you so much!

@Devessier
Copy link
Contributor

I finished the implementation and rebased, but it doesn't seem to work properly any more. I will give a look at the problem tomorrow.

@Devessier
Copy link
Contributor

It seems that the TableHotkeyScope.Table and TableHotkeyScope.Table scopes are no longer restored when the selection ends. As a consequence, the listeners I wrote are no longer working.

@lucasbordeau or @charlesBochet, do you know what I should do instead? Thanks for any help.

I will put this PR on standby for now.

@@ -61,6 +62,7 @@ export const RecordBoard = () => {
columnIdsState,
columnsFamilySelector,
recordIdsByColumnIdFamilyState,
allRecordIdsSelector,
Copy link
Member

Choose a reason for hiding this comment

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

we could refactor this into record-index to mutualize this behavior between table and board but I don't think this is the topic of this PR

[allRecordIdsSelector, setRecordAsSelected],
);

useScopedHotkeys('ctrl+a,meta+a', selectAll, TableHotkeyScope.Table);
Copy link
Member

Choose a reason for hiding this comment

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

TableHotkeyScope.Table unlikely to work on the board

recordTableId,
});

useScopedHotkeys(
Copy link
Member

Choose a reason for hiding this comment

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

this should be moved to ActionBar

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.

3 participants