Skip to content

Removed ESC from global shortcuts to locally handle it in dialog. #168

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

Closed
wants to merge 1 commit into from

Conversation

ubidefeo
Copy link
Collaborator

I introduced a bug setting ESC as a global shortcut.
The onKeyDown event in the file-list would not be passed to the <input> field with the file/folder name to trigger a .blur() and cancel the creation of a file/folder

Signed-off-by: ubi de feo <me@ubidefeo.com>
@ubidefeo ubidefeo requested a review from sebromero December 19, 2024 07:09
Copy link
Collaborator

@sebromero sebromero left a comment

Choose a reason for hiding this comment

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

I don't think this can be handled easily from within ConnectionDialog. Either you make that a singleton instance or handle the key event from the outside (probably better)

Comment on lines +1450 to +1454
// if (key === shortcuts.ESC) {
// if (state.isConnectionDialogOpen) {
// emitter.emit('close-connection-dialog')
// }
// }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove dead code

Comment on lines +16 to +20
if (state.isConnectionDialogOpen) {
document.addEventListener('keydown', onKeyDown)
} else {
document.removeEventListener('keydown', onKeyDown)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't work. A new ConnectionDialog instance is created on each render and the deregistration of the event listener doesn't catch that. As a result whenever you open the connection dialog a new event handler is added to the list which results not just in a memory leak but causes close-connection-dialog to fire multiple times.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

didn't think of that.
I believe if I handle it outside of the instance of ConnectDialog I should be able to remove it when it's destroyed.
Will investigate.
For now PR goes into Draft

@sebromero
Copy link
Collaborator

Plus I would use the key code to compare the pressed key

const ESCAPE_KEY = 27
e.keyCode == ESCAPE_KEY

@ubidefeo ubidefeo marked this pull request as draft December 19, 2024 11:15
@ubidefeo
Copy link
Collaborator Author

These changes are now part of a new branch

@ubidefeo ubidefeo closed this Dec 21, 2024
@ubidefeo ubidefeo deleted the bugfix/esc-key-event branch March 3, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants