GA-MO / react-confirm-alert

react component confirm dialog.
https://ga-mo.github.io/react-confirm-alert/demo/
MIT License
274 stars 105 forks source link

add keyboardClose with enter key #70

Closed jeffminsungkim closed 2 years ago

jeffminsungkim commented 3 years ago

This feature allow users to press enter key to close the alert. Also, after enter method will be triggered when the alert disappears.

GA-MO commented 3 years ago

@jeffminsungkim Thanks for the PR I think we should allow pressing all keyCode to close the alert up to what the user wants. Can you make prop keyCodeForClose type is Array of Number and onKeyPress?

const options = {
   keyCodeForClose: [13, 27, ...],
   onkeyPress: (event) => {
      // Do something that you want from keyboard
   }
}
jeffminsungkim commented 3 years ago

@jeffminsungkim Thanks for the PR I think we should allow pressing all keyCode to close the alert up to what the user wants. Can you make prop keyCodeForClose type is Array of Number and onKeyPress?

const options = {
   keyCodeForClose: [13, 27, ...],
   onkeyPress: (event) => {
      // Do something that you want from keyboard
   }
}

I'm not quite following. Do you want me to remove onKeypressEscape property as well? It seems like onKeyPress and keyCodeForClose props are new.

GA-MO commented 3 years ago

@jeffminsungkim Thanks for the PR I think we should allow pressing all keyCode to close the alert up to what the user wants. Can you make prop keyCodeForClose type is Array of Number and onKeyPress?

const options = {
   keyCodeForClose: [13, 27, ...],
   onkeyPress: (event) => {
      // Do something that you want from keyboard
   }
}

I'm not quite following. Do you want me to remove onKeypressEscape property as well? It seems like onKeyPress and keyCodeForClose props are new.

@jeffminsungkim Just add new props keyCodeForClose and onKeyPress