JSFiddle - React, Tailwind, and code Playground
HTML
<div>
This is some text. Open your F12 console and select some text to test me<br />
<br />
In Chromium, the selected text stays until you click twice even though it is visually unselected on the first click. In Firefox, it clears properly on one click.<br />
<br />
Why is Chromium doing this? It's causing really annoying behaviour.
</div>
JavaScript
function getSelected()
{
var return_text;
if (window.getSelection)
{
return_text = window.getSelection();
}
else if (document.getSelection)
{
return_text = document.getSelection();
}
return return_text;
}
$(document).on('click', "div", function(e)
{
var selection = getSelected();
var selectedText = selection.toString();
console.log(selectedText);
});