Selection.focusNode returns the parent node when the cursor is on a <br> element.
Here is some text containing <br>, and a JS event to get selection.anchorNode on click:
document.getElementById("textBox").addEventListener("click", (e) => {
var selection = window.getSelection();
console.log(selection.anchorNode)
})
<div id="textBox" contenteditable="true">
<p>Hello<br><br><br><br><br><br>World</p>
</div>
A click on "Hello" or "World" returns the text node containing "Hello" or "World", whereas a click on the blank line <br> returns the parent node. How can I get the <br> element next to which the click was made?