Skip to content

Bug: onfocus is not called when focused in an action #14385

Closed
@abdel-17

Description

@abdel-17

Describe the bug

The onfocus handler is not called when the focus action focuses the input.

<script lang="ts">
	let attributes = {};

	const focus = (input) => {
		input.focus();
	};
</script>

<input
	{...attributes}
	onfocus={() => console.log("onfocus", "1")}
	use:focus
/>

If you remove the object spread, it mysteriously starts working again.

<script lang="ts">
	const focus = (input) => {
		input.focus();
	};
</script>

<input
	onfocus={() => console.log("onfocus", "1")}
	use:focus
/>

Reproduction

https://svelte.dev/playground/hello-world?version=5.2.7#H4sIAAAAAAAAE42QwWrDMBBEf0Vse7DB2CRH1zL01n-oenDsdStQV8ZaJy1C_14kOZRAoL2JN7szs_JAwydCCy9ojBUXu5pJFDhpxqmECmZt0EH76oG_lzgXAVTXredlqd0ZDUd2Ghze46MlRmIHLXRuXPXCwgz0LhWwU9ArUmyQxcC86tPG6IQUPjwpispoybGY7bhFXGhaNi6F7IWPquIE6qQXZdzh62b0dB_2QkKKR8cDY6HgoCBOdU0uEsOpm_Q5tegcGhxZnDRN7XkwG0qfHEKfwzq7sLbUH7pmf93y4w3vmuzXx7w9g_yDnq-1pBSpUUjT6ZLs5-u6_v2OkKGldKX0Rbo_fow1WBv7XijYRQVVtiz3pc1hmxVS3PSKfKPncLfI8U6R_2ce_8qEChi_GFpeNwxv4QcTXTJoegIAAA==

Logs

No response

System Info

Not needed

Severity

annoyance

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions