question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AlertDialog add support for `allowsKeyboardConfirmation` prop

See original GitHub issue

🙋 Feature Request

AlertDialog is missing the feature allowsKeyboardConfirmation as defined in the API at https://github.com/adobe/react-spectrum/blob/main/packages/%40react-types/dialog/src/index.d.ts#L83.

🤔 Expected Behavior

allowsKeyboardConfirmation - Pressing the enter key closes the AlertDialog as if primary action button was clicked, which would call onPrimaryAction(). If the user has focused one of the dialog buttons or a text-area that component/element should handle the enter key event, which in the case of the button, its usePress hook will handle that.

😯 Current Behavior

Not implemented. You can see existing behavior AlertDialog behavior at https://react-spectrum.adobe.com/react-spectrum/AlertDialog.html

💁 Possible Solution

For similar functionality, the escape key closing the AlertDialog is handled by this code in an aria hook https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/overlays/src/useOverlay.ts#L69-L75

🧢 Your Company/Team

RSP

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dannifycommented, Aug 7, 2020

Right yeah I get that. This option is more for the situation where it is not the first focus event of the dialog. Maybe there are some form elements in a dialog such as a checkbox. In that case, hitting Enter would allow the user to “confirm” the dialog without having to keyboard focus the confirm button first.

0reactions
tomsontomcommented, Jan 13, 2021

I’d like to give this a try and looked a bit into the code the problem is that AlertDialog itself just uses Dialog so to implement this feature one would have to provide this feature somehow to Dialog because that’s where we’d have to attach the onKeyDown event handler into the DOM-Nodes

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dialogs - Android Developers
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill...
Read more >
AlertDialog - React Spectrum Libraries - Adobe
Documentation for AlertDialog in the React Spectrum package.
Read more >
Adding AlertDialog with Jetpack Compose to Android apps
Learn how to use Jetpack Compose in an Android app to create an alert dialog to ask users to confirm or cancel important...
Read more >
Alert Dialog Example | APG | WAI - W3C
The aria-modal property was introduced in ARIA 1.1. As a relatively new property, screen reader users may experience varying degrees of support ......
Read more >
How to change theme for AlertDialog - android - Stack Overflow
However, I just can't seem to get the app to show customized AlertDialog. Can anyone help me out with this? android · dialog...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found