AlertifyJS icon indicating copy to clipboard operation
AlertifyJS copied to clipboard

Focus is lost in mobile Safari after dropdown selection

Open rtonev opened this issue 8 years ago • 7 comments

I am using an alertify dialog to display a pop-up which includes a form.

The form has input and select fields. I am experiencing issues with both of mobile sefari. Everywhere else it seems to be working fine.

When I am trying to make a selection on my select and click "done" on mobile sarafi, the focus scrolls to the top of the page.

This is happening with the latest version, 1.5.0, as well as 1.4.1

Thanks, Rado.

rtonev avatar Nov 04 '15 20:11 rtonev

I'll need to check this, But are we talking about a modal or modeless dialog?

it would be great if you could provide an online sample.

Thanks!

MohammadYounes avatar Nov 04 '15 21:11 MohammadYounes

The issue can be reproduced on http://alertifyjs.com/examples.html

When I run the example "Button-Less Generic Dialog", if I click on the username or password field, the focus scrolls to the top of the page. So I guess it is not limited to drop downs, but is also happening with input fields.

We are using a modal dialog.

Thanks!

rtonev avatar Nov 05 '15 14:11 rtonev

Seems related to the way Safari handles showing the virtual keyboard or dropdown items list. I'll need to investigate this more.

Thanks!

MohammadYounes avatar Nov 05 '15 14:11 MohammadYounes

Thanks, appreciate it.

rtonev avatar Nov 05 '15 14:11 rtonev

Hi Mohammad,

Could you please tell me if you were able to make some progress on this issue, or if you are aware of some workaround for it.

I am not quite sure I can avoid this problem.

Thanks!

rtonev avatar Dec 08 '15 22:12 rtonev

@rtonev The issue is related to using fixed position (Safari doesn't like it), Open this on mobile Safari http://alertifyjs.com/prompt/unpin.html and you can see there is no scrolling (the unpinned dialog uses absolute position).

As a workaround, you can try the following (for basic usage):

alertify.prompt().set('onshow', function(){
  this.elements.modal.style.position = 'absolute'; 
  this.elements.modal.style.height = '100%'; 
  this.elements.modal.style.top =  ((document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop) + 'px';
});

There is a lot of code based on the dialog being in a fixed position, so the above workaround will fail in some cases and the dialog may go off-screen.

It might take a while before this enhancement gets merged into the library.

Appreciate your understanding!

Thanks.

MohammadYounes avatar Dec 08 '15 23:12 MohammadYounes

Ok tôi rất thích những contro như thế này

Phamtuan12 avatar May 30 '21 18:05 Phamtuan12