slFocus and slBlur events fire twice on slSelect component
See original GitHub issueDescribe the bug
When an slSelect component gains or loses focus, the slFocus and slBlur events are called twice.
To Reproduce Steps to reproduce the behavior:
- On https://shoelace.style/components/select add an event listener to a 
sl-selectelement in the console,$0.addEventListener('slFocus', () => console.log('slFocus')) - Focus the 
sl-selectby clicking on it slFocusis shown twice in the console- Repeat for the 
slBlurevent 
Expected behavior
The slFocus and slBlur events should just be fired once.
Issue Analytics
- State:
 - Created 3 years ago
 - Reactions:1
 - Comments:9 (7 by maintainers)
 
Top Results From Across the Web
How to prevent BLUR event from firing multiple times?
The reason it is firing multiple times is because you place another copy of the blur handler on the input element every single...
Read more >Focus and blur handlers triggered twice when switching tabs
Issue 124583: Focus and blur handlers triggered twice when switching tabs ... What steps will reproduce the problem? ... What is the expected...
Read more >Delegate focus/blur event fires twice - jQuery - Bug Tracker
Attaching focus/blur with delegation using a * selector causes handlers to be fired twice on input elements that are within a form.
Read more >OnFocus fires twice when window restored - Bugzilla@Mozilla
The problem here is the Windows OS. Windows dispatches focus and activation events in reverse order when a window is minimized and also...
Read more >Focusing: focus/blur - The Modern JavaScript Tutorial
The focus event is called on focusing, and blur – when the element loses the focus. Let's use them for validation of an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Fixed in b51978b
@claviska after further digging I found out that the
slBlur&slFocusevent handlers forsl-selectare also linked tosl-inputthat is being used in the component which is why the handler is being called twice.This means there would be no need to remove the event emmiter in
sl-selectas I suggested before.I would suggest just detaching the handler from
sl-inputhere👇🏻 so it doesn’t get emitted twice.https://github.com/shoelace-style/shoelace/blob/84d4421575c530f9145bea88b77cf06591bcf698/src/components/select/select.tsx#L409-L410