Skip to content

Conversation

@davidfou
Copy link
Contributor

Hello 👋

First of all, thanks a lot for your library, it helped me a lot with my project.

After a user selects an item, another field is focused automatically. The problem is, the Select component is still focused and pressing arrows keys are handled by it. Here is a demo (based on your comment #250 (comment)).

I'm not 100% though it was the use case reported by @jquesada2016.

Let me know what you think about that improvement/fix 😄

Closes #250

@davidfou
Copy link
Contributor Author

davidfou commented May 29, 2021

Something strange, yarn test succeeded on my machine
image

The CI report mentions 3 failures and still, it's green 🤷
image

The same problem happened already?

@rob-balfre
Copy link
Owner

Thanks for this. Will merge soon 👍

@davidfou
Copy link
Contributor Author

Hello @rob-balfre 👋

Do you have any ETA when this can be merged and released?

@rob-balfre
Copy link
Owner

When i get the time :)

@davidfou
Copy link
Contributor Author

davidfou commented Jul 4, 2021

Hey @rob-balfre 👋

Well done for improving the library and incorporating one of the tests I wrote on this PR in the master branch. Unfortunately, only one scenario is covered. The demo I shared is still relevant.

Would it be possible to merge this PR and release it? I updated my branch, so no more conflict and no test duplication.

@rob-balfre
Copy link
Owner

rob-balfre commented Jul 4, 2021 via email

@rob-balfre rob-balfre merged commit cd9e232 into rob-balfre:master Jul 5, 2021
@rob-balfre
Copy link
Owner

@davidfou released in v4.2.1 - thanks :)

@andreavaccari
Copy link

Hi, this change has caused a new bug in our application. We don't fully understand what is the root cause. However, we have confirmed that our application works correctly with v4.2.0 and breaks with v4.2.1 and v4.2.2. It is difficult to prepare a small reproducible example, so I thought to first describe the issue and see if you could intuit what's going on.

We use svelte-select inside a NodeView component for prosemirror. With the latest change in svelte-select, clicking on any item in the dropdown does not dispatch a select event. The dropdown closes as if the click happened outside of it. Mousing over an option in the dropdown and then pressing Enter or Tab (instead of clicking) triggers the select event as expected.

This only happens if svelte-select is inside a NodeView. The component works normally otherwise. Any ideas?

@yadoga
Copy link

yadoga commented Jul 10, 2021

4.2.1 is breaking selects in my app as well. Mouse clicks on options are not working any longer.

@rob-balfre
Copy link
Owner

rob-balfre commented Jul 11, 2021 via email

@yadoga
Copy link

yadoga commented Jul 11, 2021

Just tested: Select in regular Svelte REPL works, Select in new barebones SvelteKit app fails.

@yadoga
Copy link

yadoga commented Jul 11, 2021

Suspecting the deprecation of handleWindowClick in the Svelte:window listener to be the culprit.

@davidfou
Copy link
Contributor Author

I would love to give you a hand here. Would it be possible to share either a demo on the online REPL or a repo with that bug?

@yadoga
Copy link

yadoga commented Jul 11, 2021

thanks, I just set up a fresh barebones SvelteKit via npm init svelte@next my-app and added svelte-select to it.

<script>
	import Select from 'svelte-select';

	let items = [
		{ value: 'chocolate', label: 'Chocolate' },
		{ value: 'pizza', label: 'Pizza' },
		{ value: 'cake', label: 'Cake' },
		{ value: 'chips', label: 'Chips' },
		{ value: 'ice-cream', label: 'Ice Cream' }
	];
	function handleSelect(event) {
		console.log(event.detail);
	}
</script>

<h1>Welcome to SvelteKit</h1>
<Select {items} on:select={handleSelect} />

nothing more to it, i guess

@davidfou
Copy link
Contributor Author

Indeed I confirm, I have the bug as well by following your steps 👍 I think the best would be to create a ticket?

@yadoga
Copy link

yadoga commented Jul 11, 2021

@rob-balfre has seen this thread, but I opened a new issue #278 in any case.

IDontKnowMyUsername pushed a commit to IDontKnowMyUsername/svelte-5-select that referenced this pull request Nov 26, 2025
IDontKnowMyUsername pushed a commit to IDontKnowMyUsername/svelte-5-select that referenced this pull request Nov 26, 2025
Remove focus when an external field is focused programmatically
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select is always focused once initially focused

4 participants