-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Modal Dialog Backdrop lost on re-render #13543
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
Comments
Hello, I don't think this is a Svelte issue. To change the order of the elements, one of the rows must be removed from the parent before being added to the new location. The difference between Svelte 4 and Svelte 5 probably comes from the order in which this is done. I reproduced the bug in pure JS : https://jsfiddle.net/364mspte/3/ |
Thanks @adiguba. Now that I know that this is a kinda expected behaviour in browser, I looked for a workaround. A workaround would be to close and open the modal again. Here is how I could achieve it: https://svelte.dev/repl/e67c66f9b9b947978b888b3aa12c60b3?version=4.2.19 the only down side is that the UI blinks, which should be fine for this edge case. |
Another solution would be to use svelte-portal. |
Amazing, the svelte 5 demo works, but it does not work for the svelte 4. So for the time being I should stick with the workaround. |
The moveBefore api will solve the issue. Instead of removing and adding the element again, we should move element. |
I tried it quickly, and it's work fine... But there something I din't understand : the doc say it's a function in the Node prototype, but in fact actually it's in the Element prototype !? |
I remember seeing this demo quite a while ago, maybe the spec was not finalized at that point and the demo is now out of date. In any case, this probably could be implemented as a progressive enhancement for browsers implementing it 👍 |
I will push a PR, but I don't known how to test that... |
Describe the bug
When using "#each" block and then re-order the items of the array, if we have a "dialog" element open as modal inside a row, and if the items goes to a lower index, the "::backdrop" psudo element get lost. Notice that "::backdrop" psudo element is not get lost if the new index is higher.
I tried it with Svelte 5 and I noticed that it happens the other way round. (the index lower and higher)
Reproduction
I made a Repl to demonstrate the issue:
Issue on Svelte 4 and 3:
https://svelte.dev/repl/0f7b410a6c9c413f82c8bb9e14a66824?version=4.2.19
Issue On Svlelte 5:
https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE41V247jNgz9Fa67QBLAjScD9MVjB1gMULRoO_uwC_QhzoNiyWNhZMmQmM0Ehv-90MWXXAbdhyAWycNDHtF0F1VcMBOluy6SpGFRGn1p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uUnTBb4baQA9Wdzbvv_wMGekPENAkAAA==
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: