Alert followed by toast body padding-right issue
See original GitHub issueCurrent behavior
When opening an alert, with scrollbarPadding: true
(default), and then chaining a toast to it, the toast seems to inherit the alert’s states.previousBodyPadding
, setting a body padding even without a backdrop or removal of the scrollbar. Somewhat related to #678
Note that this doesn’t replicate if the script is triggered straight on page load, presumably because not all elements have been properly rendered yet.
Note 2: this applies when using mixins instances too:
const alert = Swal.mixin({
heightAuto: false,
buttonsStyling: false,
customClass: {
confirmButton: "btn btn-primary " + defaultClasses,
cancelButton: "btn-secondary " + defaultClasses
},
scrollbarPadding: false
});
const toast = Swal.mixin({
toast: true,
type: "success",
showConfirmButton: false,
timer: 3000,
position: "top"
});
export default Swal;
export { alert, toast, Swal as swal, defaultClasses }
async deleteProduct(productId) {
var res = await alert.fire({
type: "warning",
title: "Do you want to delete this?",
customClass: {
cancelButton: "btn-outline-primary " + defaultClasses,
confirmButton: "btn-danger " + defaultClasses
},
showCancelButton: true,
cancelButtonText: "No, don't delete",
confirmButtonText: "Yes, delete",
reverseButtons: true,
focusCancel: true
});
if (res.value === true) {
await api.delete("products/" + productId);
var index = this.products.findIndex(a => a.productId == productId);
this.$delete(this.products, index);
toast.fire({
title: "Deleted",
timer: 3000,
});
}
}
Expected behavior
Alert should restore the body’s padding and the toast shouldn’t set any body padding.
Live demo
https://dolomite-saver.glitch.me/ https://jsfiddle.net/n1dbypfa/
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (10 by maintainers)
Top Results From Across the Web
Bootstrap 4 snackbar / toast - Stack Overflow
I (emphasis = full disclosure) created a jQuery plugin for the toasts components to make them easier to use, the repo can be...
Read more >Bootstrap Toast Not Working - Laracasts
Bootstrap Toast Not Working. Im sorry, its probably something so simple but I just cannot seem to get it to work, but I...
Read more >Toasts - Bootstrap
Push notifications to your visitors with a toast, a lightweight and easily customizable alert message. Toasts are lightweight notifications designed to mimic ...
Read more >Webpack issue loading CSS - Material Design for Bootstrap
Topic : Webpack issue loading CSS ... solid rgba(0,0,0,.05)}.toast-body{padding:.75rem}.modal-open{overflow:hidden}.modal-open .modal{overflow-x:hidden ...
Read more >Notify API Quickstart - Alchemy Docs
The Notify API manages transaction notifications using webhooks. ... margin-right: -0.375rem;\n margin-left: 0.75rem;\n}\n\n.toast-body {\n padding: 0.75rem ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @limonte!
Currently this is working for the first ~150ms (i.e. animation duration). The following code:
causes the following error in console:
I think the reason is that after the animation is finished, we call the
unsetWeakMap()
. And that makes the instance methods not accessible. I’m going to fix this as well then because to me it’s a bug.Thanks @limonte. A couple of more questions (they are all related to the fix I’m coding for this issue):
getInput()
) supposed to work in thethen
?onClose
function, what are the instance methods called in the thethen
of the main Swal supposed to refer to? For example the following code:Currently is printing:
So it’s clearly referring to the Swal fired in the
onClose
. Is this the expected behaviour?