Closed Neptunium1129 closed 2 months ago
duplicate of #11973
duplicate of #11973 I agree But this problem is cause svelte mount.
11973 is svelte fade
Locally, I enabled legacy.componentApi
and modified the code to
return function ModalComponent(anchor, props_) {
let options = props_ ? {
target: anchor.nodeType == 8 ? anchor.parentNode : anchor,
props: props_,
} : anchor;
return new Component({
...options,
props: {
...props,
...options.props,
},
});
And it still does double mounting. Well, under the hood, it still uses mount()
.
Also, for some reason, with enabled it tries to mount to a comment node :Dlegacy.componentApi
Hm, this
return function ModalComponent(anchor, props2) {
return Component(
anchor,
{
...props,
...props2,
});
};
doesn't cause double mounting.
If you do manual mounting, it's your responsibility to do manual unmounting. It just happened that at some points, Svelte sweeps away your manually mounted Popups. You can confirm this by adding an onDestroy logger to the Popup - it never logs in your REPL.
thanks!!
As pointed out, adjusting the generated code will resolve the issue. The problem was that calling mount
was wrong in this instance, because the component is rendered by the framework, not instantiated manually. What the bind method does is decorate the component. here's the fixed playground.
Therefore closing.
Note this is all deep into advanced Svelte territory, so it's totally understandable that it's not easy to grasp right away.
I just looked at the document, but it seems like something is very different. Thank you very much.
Describe the bug
https://github.com/flekschas/svelte-simple-modal
Breaking changes https://svelte-5-preview.vercel.app/docs/breaking-changes -- Components are no longer classes
i changed code new component code
old
new
Simplemodal4.svelte
The temporary solution is to add "event.target.blur()" in the onclick function. However, this issue does not occur in Svelte 3 or 4.
Reproduction
REPL SVELTE5
Logs
No response
System Info
Severity
annoyance