fancyapps / ui

A library of JavaScript UI components, includes the best lightbox - Fancybox5
https://fancyapps.com/
Other
820 stars 99 forks source link

Flash of content on close() in Safari 17.4.1 #642

Closed brendon closed 7 months ago

brendon commented 7 months ago

Describe the bug

In Safari 17.4.1 (at least) if you click 'Launch Dialog' (not Clone) here: https://jsfiddle.net/dspr7gxh/ then click the close button, you'll see the content of the div briefly when it's put back in its original place in the DOM before it's hidden.

There seems to be some kind of animation going on there that doesn't seem to occur in Chrome or Firefox.

Reproduction

https://jsfiddle.net/dspr7gxh/

Additional context

https://github.com/fancyapps/ui/assets/81871/4343cb72-6b58-49de-936f-c4f3ae5ff644

fancyapps commented 7 months ago

Hi! Thanks for the reporting! This is something with Safari v17.4 as it works fine in previous versions. This will be fixed in the next release.

brendon commented 7 months ago

No worries @fancyapps :) Safari introduced a new engine for inline content in 17.4 that has also wrecked some layout stuff for us around radio buttons and labels. All the best :)

fancyapps commented 7 months ago

It should be fixed in the latest release - https://jsfiddle.net/1zqckn4p/

brendon commented 7 months ago

Looks good to me :) Thanks again @fancyapps.

brendon commented 7 months ago

Hi @fancyapps, sorry to be a pain but it still seems to be a problem in my particular app (not in the jsfiddle though). Are you able to let me know how you solved it in case I'm overriding some CSS or something in my particular situation?

fancyapps commented 7 months ago

@brendon First, are you sure you are using the latest version? Because, if you're using standard CDN links, for example, you might be using a cached previous version. The jsfiddle demo I gave earlier uses a fixed version of 5.0.36.

Then, could you share an online page/demo? If you don't want to post this publicly, please join Discord and DM me.

Anyway, I believe this is a Safari bug. It triggers a CSS animation on an element after it changes the parent DOM element, even if the element has style="display:none" and CSS class, that previously triggered the CSS animation, is removed. The only way I could think of to fix this is to trigger the reflow after setting display:none, otherwise Safari ignores this style and not only makes the element visible, but also runs the animation.

brendon commented 7 months ago

I feel like an idiot, I set a resolutions override in my package.json to keep it at version 5.0.33 because of the bug. Sorry to have wasted your time!

That was an interesting explanation. Certainly sounds like a bug in Safari. Not sure how readily they fix those though...

therelapse commented 6 months ago

We also encountered this problem. However, Safari version 17.5 has now been released and the window began to close normally, without updating the fancyapps/ui package.