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

input field not functional when used on top of a bootstrap modal #412

Closed
mteichtahl opened this issue Jul 29, 2015 · 23 comments
Closed

input field not functional when used on top of a bootstrap modal #412

mteichtahl opened this issue Jul 29, 2015 · 23 comments

Comments

@mteichtahl
Copy link

I am currently calling swal from within a bootstrap modal. It seems that the buttons work but the input of the swal is not accepting a click nor does it ever take focus. I'm wondering if this is a known issue or possibly something I'm doing.

@KillerSquid
Copy link

I had the same issue. What I ended up doing was 'hiding' the modal with modal.hide, opening the swal, doing whatever you need with the inputValue, then show the modal with modal.show on success or cancel of the swal.
Hope this helps.

@mteichtahl
Copy link
Author

Dan
I found a fix for this. I'll post it tomorrow 

Sent from Outlook

On Mon, Aug 10, 2015 at 6:52 AM -0700, "Dan Kaufman" notifications@github.com wrote:

I had the same issue. What I ended up doing was 'hiding' the modal with modal.hide, opening the swal, doing whatever you need with the inputValue, then show the modal with modal.show on success or cancel of the swal.

Hope this helps.


Reply to this email directly or view it on GitHub.

@diederik555
Copy link

Hi mteichtahl,

Did you stil post the fix? I can not find it. Would really help!

@YannDanthu
Copy link

Hi,

Same issue with sweet alert (as well as sweetalert2).
The input field does not get the focus on firefox only. This happens only when opening a swal from a bootstrap modal.

Cannot figure out the problem yet. Really strange.

@Cu4rach4
Copy link

I have the same problem...any one have a solution?

@Cu4rach4
Copy link

hi, this allow to show input placeholder, but is not fix to focus on input...

#537

@lynnpen
Copy link

lynnpen commented Jul 15, 2016

I have the same problem, can't find the fix...

@S0c5
Copy link

S0c5 commented Jul 17, 2016

+1

@Cinamonas
Copy link

Cinamonas commented Jul 22, 2016

I found that the culprit is tabindex="-1" that's set on Bootstrap's modal.

The fix:

// call this before showing SweetAlert:
function fixBootstrapModal() {
  var modalNode = document.querySelector('.modal[tabindex="-1"]');
  if (!modalNode) return;

  modalNode.removeAttribute('tabindex');
  modalNode.classList.add('js-swal-fixed');
}

// call this before hiding SweetAlert (inside done callback):
function restoreBootstrapModal() {
  var modalNode = document.querySelector('.modal.js-swal-fixed');
  if (!modalNode) return;

  modalNode.setAttribute('tabindex', '-1');
  modalNode.classList.remove('js-swal-fixed');
}

@timm3
Copy link

timm3 commented Jul 28, 2016

I have a nearly identical issue, except it only occurs if the modal is so tall that it is scrollable on the y-axis.

@eminumut
Copy link

Please help me...

@navas
Copy link

navas commented Mar 14, 2017

Cinamonas's tab fix didn't work for me :(

@Alagaesia93
Copy link

Alagaesia93 commented Apr 5, 2017

+1
@eminumut @navas
Have you called fixBootstrapModal() before showing swal? I forgot to do that at first, but now works perfectly!

Thank you @Cinamonas

@eminumut
Copy link

eminumut commented Apr 9, 2017

@Alagaesia93

Would you show me some examples?

@Alagaesia93
Copy link

Alagaesia93 commented Apr 11, 2017

@eminumut

fixBootstrapModal()
swal({whatever}, function(isConfirm){
whatever
restoreBootstrapModal()
}

It works for me :)

@caleb87
Copy link

caleb87 commented Jun 27, 2017

The fix generates a syntax error in IE11

@Cinamonas
Copy link

Cinamonas commented Jun 28, 2017

@caleb87, I've updated the snippet not to use arrow functions and const.

@t4t5
Copy link
Owner

t4t5 commented Sep 8, 2017

This seems to be an issue with Bootstrap so I will close for now. Thanks for the fix @Cinamonas!

@t4t5 t4t5 closed this as completed Sep 8, 2017
@gopal9999
Copy link

Hi , I have faced the same issue .
This issue can be solved by removing { tabindex="-1" } from Bootstrap Modal.
It's work fine for me.

@ghost
Copy link

ghost commented Jan 14, 2018

Does anyone know how to apply this fix in R? I'm having the same issue, but my attempts to convert it to R have failed so far

@jhoanborges
Copy link

I found that the culprit is tabindex="-1" that's set on Bootstrap's modal.

The fix:

// call this before showing SweetAlert:
function fixBootstrapModal() {
  var modalNode = document.querySelector('.modal[tabindex="-1"]');
  if (!modalNode) return;

  modalNode.removeAttribute('tabindex');
  modalNode.classList.add('js-swal-fixed');
}

// call this before hiding SweetAlert (inside done callback):
function restoreBootstrapModal() {
  var modalNode = document.querySelector('.modal.js-swal-fixed');
  if (!modalNode) return;

  modalNode.setAttribute('tabindex', '-1');
  modalNode.classList.remove('js-swal-fixed');
}

genius

@MateusFGoncalves
Copy link

For those who have more than one modal, you can use:
Documento sem título (1).pdf

@Rubncal04
Copy link

It doesn't work for me, I have the same issue. can anyone help me or tell me what's my problem?

fixBootstrapModal()
Swal.fire({whatever}).then((result) => {
restoreBootstrapModal()
})

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

No branches or pull requests