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

Feat: Add keyboard shortcuts for closing modal (Escape) and submitting (Enter) in File Upload Window #802

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

dhairyashiil
Copy link
Contributor

Brief Title

Feat: Add keyboard shortcuts for closing modal (Escape) and submitting (Enter) in File Upload Window

Acceptance Criteria fulfillment

  • Pressing the Enter key triggers the submission of the file and prevents the default behavior (such as adding a new line in the text area) when the user is inside the input fields for the filename or description.
  • Pressing the Escape key closes the window when the user is inside the input fields for the filename or description.

Fixes #801

Video/Screenshots

Enter.key.file.upload.mp4

PR Test Details

Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-802 after approval. Contributors are requested to replace <pr_number> with the actual PR number.

Copy link
Collaborator

@Spiral-Memory Spiral-Memory left a comment

Choose a reason for hiding this comment

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

LGTM !

@dhairyashiil
Copy link
Contributor Author

LGTM !

Thank you Zishan😄

@Spiral-Memory
Copy link
Collaborator

Hey, this only works, when i am focussed on input box, can't we do it without that ?

@dhairyashiil
Copy link
Contributor Author

Hey, this only works, when i am focussed on input box, can't we do it without that ?

Yes, at first, I tried that by setting an event listener for the 'Enter' and 'Escape' keys, but that is causing one issue: after pressing the 'Enter' key, it uploads the given file and then opens another window to select the file.

Please refer to this screenshot:
this window is opened again -
image

@Spiral-Memory
Copy link
Collaborator

The reason is, after click on the attachment button, the focus is still on the attachment icon and not on the modal

@dhairyashiil dhairyashiil force-pushed the feat/keyboard-shortcuts-file-upload branch from 13b372a to 041c854 Compare January 6, 2025 04:41
@dhairyashiil
Copy link
Contributor Author

The reason is, after click on the attachment button, the focus is still on the attachment icon and not on the modal

Hello @Spiral-Memory,
I believe this issue has been fixed by my PR #736.

I have added the event listener logic for the 'Enter' key. I haven't added logic for the 'Escape' key since its default behavior is to close the window.

Please take a look at the video below to see the changes:

Added.EventListener.for.Enter.key.mp4

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.

Feat: Add keyboard shortcuts for closing modal (Escape) and submitting (Enter) in File Upload Window
2 participants