Skip to content

ontoggle in details is fired before updating bind:open #17305

@keithyipkw

Description

@keithyipkw

Describe the bug

ontoggle should be fired after updating bind:open, not before. Quote from https://svelte.dev/docs/svelte/basic-markup#Events

Timing-wise, event attributes always fire after events from bindings (e.g. oninput always fires after an update to bind:value).

Reproduction

The following code can reproduce the problem in the Svelte playground

<script>
	let bindingState = false;
	
	let ontoggleState = false;
	
	const ontoggle = () => {
		ontoggleState = bindingState;
	}
</script>

<details bind:open={bindingState} ontoggle={ontoggle} >
<div>Opened</div>
</details>

<p>
	Reactive value: {bindingState}
</p>

<p>
	Reactive value inside ontoggle: {ontoggleState}
</p>

Logs

System Info

svelte: 5.45.5

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions