Issue with selectionFromDOM in Chrome (works on Firefox)

Hey there!

This is my first time posting here, so apologize in advance for any mistake.

I’m facing an issue with keyboard arrow navigation and selection. Basically, I have a document where we have (very simplified version):


The issue happens when I have some text selected in the paragraph after the media and I try to go backward. I will expect the image and the first paragraph to get selected at some point, but it never happens:

Notice that the issue only happens in Chrome and Safari but works on Firefox



I added a log inside the selectionFromDOM method to show what the value of domSel.focusNode is, and that seems to be the difference between Chrome and Firefox. In Chrome, the document.getSelection() returns the media element and never gets into the previous paragraph, while in Firefox, the media element never gets selected and the previous paragraph gets selected.

Thanks and please let me know if I can provide any other information

The problem doesn’t appear to occur with simple elements like an <hr>. Could you take a look what the minimal DOM structure for the media elements that triggers the problem is?