Skip to content
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

Svelte 5: Chrome: svelte-select list is not opened on the first click (same code of Svelte 4) #11691

Closed
frederikhors opened this issue May 20, 2024 · 21 comments · Fixed by #11695

Comments

@longnguyen2004
Copy link

It works for me just fine, in both non-runes and runes mode.

@frederikhors
Copy link
Author

It works for me just fine, in both non-runes and runes mode.

The issue is the list is not opening when you first click without writing.

@frederikhors
Copy link
Author

I tried Firefox and it works! Chrome doesn't!

@frederikhors frederikhors changed the title Svelte 5: svelte-select list is not opened on the first click (same code of Svelte 4) Svelte 5: Chrome: svelte-select list is not opened on the first click (same code of Svelte 4) May 20, 2024
@longnguyen2004
Copy link

Yes, Chrome Canary 127.0.6490.0 also breaks, Edge 125.0.2535.51 works fine

@frederikhors
Copy link
Author

Wow. Now we have to understand if it's a Svelte 5 or a Chrome bug... :(

@longnguyen2004
Copy link

Also it seems to be intermittent, I just tested again and now it works? Not sure what's going on here

@frederikhors
Copy link
Author

Are you sure you didn't pressed any keyboard key? Because if you do the list appears. The issue is the first click only.

@longnguyen2004
Copy link

Yes, it works fine, but I've also seen it breaks, so it's pretty confusing. Let's wait for the dev then.

2024-05-20.18-29-27.mp4

@frederikhors
Copy link
Author

Which Chrome version is this?

@longnguyen2004
Copy link

Same as above, Canary 127.0.6490.0

@trueadm
Copy link
Contributor

trueadm commented May 20, 2024

So this looks like a really ugly Chrome bug. Essentially, pointerup is registered to the DOM element, but Chrome isn't invoking it on select elements – at all? If you change it to a click inside svelte-select then it works fine.

https://github.com/rob-balfre/svelte-select/blob/master/src/lib/Select.svelte#L682

I'll keep digging as to why this is the case though, as it works in Svelte 4.

@trueadm trueadm closed this as completed May 20, 2024
@trueadm trueadm reopened this May 20, 2024
@trueadm
Copy link
Contributor

trueadm commented May 20, 2024

Okay this seems to be because we use cloneNode on the template that generates the div, using importNode resolves the problem – however, that doesn't seem like ideal. This is definitely a Chrome bug.

@gterras
Copy link

gterras commented May 20, 2024

For what it's worth this seems to be working as expected on Chrome 125 linux (debian).

simplescreenrecorder-.5.webm

@trueadm
Copy link
Contributor

trueadm commented May 20, 2024

For me, the dropdown never opens at all in Chrome 125 or Chrome canary. It seems that pointer events are not working correctly with cloneNode. Interestingly, mouseup works fine.

@trueadm
Copy link
Contributor

trueadm commented May 20, 2024

It seems that adding point events to DOM elements that were cloned and not attached when the event handler is added is what causes this issue:

https://jsfiddle.net/x8u742cL/1/

@frederikhors
Copy link
Author

Should we open a bug on Chrome or it's a bug everywhere else is working right now?

@trueadm
Copy link
Contributor

trueadm commented May 20, 2024

I think someone should report it to Chrome, as this bug only occurs in Chrome – not even Edge. On the other-hand, we might be able to mitigate this in Svelte by attaching inline event handlers after we append to the DOM.

Update: we can't really add events later, because it breaks the ordering with other directives like bind:, use: and transition: which both expect event handlers to have run in an order they understand. This is a tricky one for sure.

@frederikhors
Copy link
Author

@Rich-Harris @trueadm can you please release this ASAP?

@atjn
Copy link

atjn commented May 27, 2024

@trueadm Chrome is currently improving their pointer event logic as part of WPT Interop 2024. I checked and there does not seem to be any tests for this problem. Chances are that if you contribute a test, Chrome will fix it by the end of the year.

@Neptunium1129
Copy link

is It seems to be working fine without any problems now.

  • 125.0.6422.142(공식 빌드) (64비트)

@trueadm
Copy link
Contributor

trueadm commented May 31, 2024

That’s because we fixed it

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 a pull request may close this issue.

6 participants