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

[Enhancement] - Enable the use of Enter keys for modals #527

Open
leekahung opened this issue Nov 15, 2023 · 18 comments
Open

[Enhancement] - Enable the use of Enter keys for modals #527

leekahung opened this issue Nov 15, 2023 · 18 comments
Labels
enhancement Enhancement of existing features

Comments

@leekahung
Copy link
Contributor

leekahung commented Nov 15, 2023

Describe the Current Behavior/Feature:

More related to Quality of Life changes as oppose to make the functions work.

While we have functioning modals doing what we want them to be doing, the submission of these modals are relegated to simply clicks. If there could be a way to simply perform the same action, but with the enter key, that would be nice. This type of change would be ideal for modals which only rely on buttons and doesn't have any textfields/input fields involved.

For example, if user wishes to log out, they could simply hit the "enter" key when the logout modal pops up as an alternative to clicking.

Or if we wish to push this further, we could also get these enhancements to work with modals with textfields/input fields, we could have the "enter" key work after the user exited the fields.

Rationale:

Ease of actions that would augment what we have with mouse presses.

Proposed Implementation (if applicable):

Include a listener when entering modals that would help perform actions with return.

Additional context:

Initially have this enhancement in mind for modals like the logout and inactivity message (see screenshot):

Screen Shot 2023-11-15 at 15 26 42

But could be expanded to other modal like add contacts or new message if it's something we think would be useful.

@leekahung leekahung added the enhancement Enhancement of existing features label Nov 15, 2023
@JonnyMc94
Copy link
Contributor

Hi @leekahung, I would like to work on this solution for the Logout and Inactivity modals if possible?

@leekahung
Copy link
Contributor Author

Hi @leekahung, I would like to work on this solution for the Logout and Inactivity modals if possible?

Sure, give it a go.

@xscottxbrownx
Copy link
Contributor

xscottxbrownx commented Nov 21, 2023

@leekahung @JonnyMc94
The ESC key already works by default with MUI.

Enter key works when focused on the button desired.
I guess we could autofocus on buttons when modal appears, if that made sense - like Logout modal...

Could make modal functions fire on Enter key press when in text fields as an approach as well - I haven't tested to see if this is already working or not.

@leekahung
Copy link
Contributor Author

@leekahung @JonnyMc94
The ESC key already works by default with MUI.

Enter key works when focused on the button desired.
I guess we could autofocus on buttons when modal appears, if that made sense - like Logout modal...

Could make modal functions fire on Enter key press when in text fields as an approach as well - I haven't tested to see if this is already working or not.

We got the enter key press working for the pod server input field, so I think we could try a similar strategy

@xscottxbrownx
Copy link
Contributor

We got the enter key press working for the pod server input field, so I think we could try a similar strategy

The field on login page? That doesn't work for me. Or am I thinking of the wrong thing?

The enter key works just fine on the Add Contacts modal, and also Add Documents. Although Add Documents is a little strange because you have to have chosen a file to upload first & if you hit enter on SelectDocumentType it doesn't really work due to it being a select menu - it causes the dropdown to open/close. But if you were on any other input it would work - see video:

Screen.Recording.2023-11-21.at.7.55.36.PM.mov

Enter key also works fine on Sharing a document modal - SetACLPermissionsModal.

So seems:

  1. esc key works on all I tested (may have missed one possibly)
  2. enter key works on all modals that contain a <form>, but not just the <Dialog> modals with one (typically the single question yes/no dialogs.)
  3. could be solved with an autofocus on the "yes" action of the <Dialog> modals

@leekahung does that sound like an okay approach? Or did you have something else in mind?

@leekahung
Copy link
Contributor Author

The field on login page? That doesn't work for me. Or am I thinking of the wrong thing?

No, I think you're right about the Enter key no longer working anymore. It had worked before (see PR #340), but was think it might have broke from our recent update from the original input field to MUI <Autocomplete>. In any case:

  1. esc key works on all I tested (may have missed one possibly)
  2. enter key works on all modals that contain a <form>, but not just the <Dialog> modals with one (typically the single question yes/no dialogs.)
  3. could be solved with an autofocus on the "yes" action of the <Dialog> modals

@leekahung does that sound like an okay approach? Or did you have something else in mind?

I like the idea with the auto-focus upon enter the modal. Though, I'm not sure if auto-focusing on the button would require users to hit ESC twice, once to de-focus the button, twice to exit the modal. I'll say we should give it.

For now, I'll update this issue to simply enabling Enter key. With this approach, think we could also patch up the new login on Enter key bug along the way.

@leekahung leekahung changed the title [Enhancement] - Enable the use of Enter/ESC keys for modals [Enhancement] - Enable the use of Enter keys for modals Nov 22, 2023
@JonnyMc94
Copy link
Contributor

Hi @leekahung. Just to confirm, this enhancement is now related to enabling the enter key for the logout, inactivity and login modals?

@leekahung
Copy link
Contributor Author

Hi @leekahung. Just to confirm, this enhancement is now related to enabling the enter key for the logout, inactivity and login modals?

Yes. A good bonus would be to enable the enter key for all modal, including the ones that has input fields or text fields in them.

@andycwilliams
Copy link
Member

@JonnyMc94 Are you working on this? If so, feel free to assign yourself to it.

@JonnyMc94
Copy link
Contributor

Hi @andycwilliams, yes I'm currently working on this. It looks like I can't assign myself?
Screenshot 2023-11-25 at 22 27 26

@andycwilliams
Copy link
Member

Ah, it may be because you're a contributor and not technically a member of the GitHub group. Anyway I assigned you.

@JonnyMc94
Copy link
Contributor

Apologies for the lack of movement on this guys. I have changes I'm currently working on and hope to have them pushed in the next few days.

@andycwilliams
Copy link
Member

Apologies for the lack of movement on this guys. I have changes I'm currently working on and hope to have them pushed in the next few days.

It's alright. A couple of weeks isn't an enormous amount of time with no movement. Besides, it's the holiday season so things are a bit slower overall.

@xscottxbrownx
Copy link
Contributor

@JonnyMc94 still working on this?

@JonnyMc94
Copy link
Contributor

@xscottxbrownx I did some work on this over the holidays but was having issues. I couldn't get the focus on the submit button when the modal opened. I worked around this by placing an event listener on the modal itself. This worked but unfortunately then ran into a bug with executing functionality on modal close e.g logging out, submitting form content/alerting user of empty required form content.
It may need a more experienced hand than mine so if anyone else wants to work on it feel free!

@andycwilliams
Copy link
Member

@JonnyMc94 Any progress?

@andycwilliams
Copy link
Member

@JonnyMc94 Once again seeing if you have any updates

@andycwilliams
Copy link
Member

Unassigning due to lack of response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing features
Projects
None yet
Development

No branches or pull requests

4 participants