This helper prevents the focus ring on mouse interaction for bootstap buttons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This helper prevents the focus ring on mouse interaction on buttons | |
*/ | |
import forEach from 'lodash-es/forEach'; | |
forEach(...[document.querySelectorAll('.btn')], (element) => { | |
let mouseDown = false; | |
element.addEventListener('mousedown', () => { | |
mouseDown = true; | |
}); | |
element.addEventListener('mouseup', () => { | |
mouseDown = false; | |
}); | |
element.addEventListener('focus', (event) => { | |
if (mouseDown) { | |
event.target.blur(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment