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: overlays, enter key to dismiss dialog with inputs #21665

Open
cjorasch opened this issue Jul 2, 2020 · 4 comments
Open

feat: overlays, enter key to dismiss dialog with inputs #21665

cjorasch opened this issue Jul 2, 2020 · 4 comments
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement

Comments

@cjorasch
Copy link

cjorasch commented Jul 2, 2020

Feature Request

Ionic version:
[x] 5.2.3

Describe the Feature Request
When running in a desktop browser, it is common to be able to use the Enter and Escape keys to dismiss alert dialogs.

For example, "Are you sure you want to..." with OK and Cancel buttons.

Describe Preferred Solution
Add a way to indicate this behavior when specifying the buttons to be displayed.

Possible approaches:

  • role value to indicate the accept button (similar to current cancel behavior)
  • property to indicate keyboard binding for buttons so enter could be specified as well as keys for other buttons.
@ionitron-bot ionitron-bot bot added the triage label Jul 2, 2020
@brandyscarney brandyscarney added package: core @ionic/core package type: feature request a new feature, enhancement, or improvement labels Aug 20, 2020
@HyperLife1119
Copy link

I hope this feature can be seen in V6 versions. @liamdebeasi

@liamdebeasi liamdebeasi changed the title feat: ion-alert: support Enter key to close the dialog feat: overlays, enter key to dismiss dialog Nov 8, 2021
@liamdebeasi liamdebeasi added type: feature request a new feature, enhancement, or improvement and removed type: feature request a new feature, enhancement, or improvement labels Nov 8, 2021
@liamdebeasi
Copy link
Contributor

Hi everyone,

The team is reviewing feature requests in our backlog. Is anyone able to clarify why they would like to dismiss overlays with the "Enter" key? A code example of the problem you are running into would also be helpful.

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Nov 22, 2022
@cjorasch
Copy link
Author

It looks like this is now working for alerts that do not include inputs in the options.

    const alert = await alertController.create({
        header,
        message,
        buttons: [
            {
                text: 'Cancel',
                role: 'cancel',
            },
            {
                text: 'OK',
            },
        ],
    });
    alert.present();

This works and the user is able to use the Enter and Escape keys to confirm or cancel the alert.

If you include inputs:

    const alert = await alertController.create({
        header,
        message,
        inputs: [
            {
                type: 'text',
                name: 'value',
                value,
            },
        ],
        buttons: [
            {
                text: 'Cancel',
                role: 'cancel',
            },
            {
                text: 'OK',
            },
        ],
    });
    alert.present();

Then the Enter key does not close the alert. This is different from window.prompt where the user is able to use the Enter key.

The general use case is for users who are working on a desktop browser and want to work from the keyboard without going back and forth to the mouse when entering information. This is also the case for things like being able to set focus when a dialog is displayed.

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Nov 22, 2022
@liamdebeasi liamdebeasi changed the title feat: overlays, enter key to dismiss dialog feat: overlays, enter key to dismiss dialog with inputs Nov 29, 2022
@liamdebeasi liamdebeasi added type: feature request a new feature, enhancement, or improvement and removed triage type: feature request a new feature, enhancement, or improvement labels Nov 29, 2022
@colabottles
Copy link

For accessibility reasons, an alert should be closed if there are no interactive elements (e.g., "close", "save", etc.) with the ESC key. Any interaction in the alert dialog, should be tabbable and closed with either the ENTER key on input of the choice OR dismissable with the ESC key. This is for the most part (95%+) the behavior I have seen over the years with testing and auditing for accessibility and testing with people with disabilities.

An overlay (totally separate entity from an alert dialog) should be dismissable with either clicking off with the mouse or by initiating a trigger (an "x" for instance) in the overlay and then using the ESC key. Changing the default behavior of native HTML components is strongly discouraged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests

5 participants