GA-MO / react-confirm-alert

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

How add autoFocus: true on buttons #51

Closed christiantigre closed 2 years ago

christiantigre commented 4 years ago

How I can add el autoFocus on buttons Label: "Yes" I try added autoFocus: true, but, don't work autoFocus

submit = () => {
    confirmAlert({
      title: 'Confirm to submit',
      message: 'Are you sure to do this.',
      buttons: [
        {
          autoFocus: true,
          label: 'Yes',
          onClick: () => alert('Click Yes')
        },
        {
          label: 'No',
          onClick: () => alert('Click No')
        }
      ]
    });
  };

Any solution?

abdellani commented 4 years ago

Hi I don't think that this is possible, as you can see, the code doesn't expect to get additional attributes for the buttons.

              <div className='react-confirm-alert-button-group'>
                {buttons.map((button, i) => (
                  <button key={i} onClick={() => this.handleClickButton(button)} className={button.className}>
                    {button.label}
                  </button>
                ))}
              </div>
GA-MO commented 2 years ago

This feature is in Version 3.0.0

Drew-Shumski commented 5 months ago

autofocus not working when modal is shown after some event