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.

Closing alert will scroll to the selected button

See original GitHub issue

Hi When closing an alert, if the selected button is out of the screen, the scroll will automatically change to show the selected button. This can be replicated in the examples at GH pages by selecting one example, scrolling, and pressing enter.

This is particularly annoying, as I’m using sweetalert where the “activate” button is in a header with bootstrap “sticky-top” class, so when closing the modal it will always scroll to the top. This last problem is only present at Google Chrome.

I’m using a default sweetalert button:

swal({
  titleText: "Test alert",
  text: "This is a test alert"
});

Is there a way to fix this(or disable if it is a wanted feature)?

Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
limontecommented, Sep 28, 2018

Maybe there is a technical reason why it has to go there.

Yes, .then() is happening before the end of modal animation and before restoring the focus to the last active element.

Either way, there are ways to work around it but it does add some additional complexity that perhaps isn’t necessary.

I agree about a bit of overhead, but it’s really just a bit of it:

var swalResult
Swal({
  onAfterClose: () => {
    console.log(swalResult)
  }
}).then(result => {
  swalResult = result
})
2reactions
angrykoalacommented, Nov 29, 2017

Oh, well, fastest weekend of my life Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

SweetAlert2 scrolls to initiating element after close
As you can see I'm trying to force the scroll to the top in multiple areas and this works, but then it snaps...
Read more >
Window.scroll() - Web APIs - MDN Web Docs
The Window.scroll() method scrolls the window to a particular place in the document.
Read more >
Alerts - Presentation - Human Interface Guidelines - Design
The default button can cancel the alert or perform the most likely nondestructive ... Although an alert might scroll if the text size...
Read more >
ion-alert: Ionic API Alert Buttons with Custom Message Prompts
If a handler returns false then the alert will not automatically be dismissed when the button is clicked. All buttons will show up...
Read more >
Scrollspy · Bootstrap v5.0
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted....
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