1

If you drag-and-drop around an image in Firefox in a contenteditable area, sometimes the images will end up being selected like this:

Selected image

Fiddle here: http://jsfiddle.net/zupa/qg5Qh/

You may need to drag-drop it a few times, I have this bug in like 20+% of the time.

I am using Firefox 13.0.1 on Windows 7

How to remove that selection? Any help is appreciated.

Ps:

  • It is not available as a range via document.getselection().getRangeAt(..)
  • Firefox does NOT add any HTML attributes, still if I hit save (custom CMS), and reload the page in contenteditable mode, the selection comes back. Seems to be an annoying bug.
zupa
  • 12,809
  • 5
  • 40
  • 39

1 Answers1

3

It does it reliably when the image is within a word that is marked by Firefox as a spelling error. For example, here's your jsFiddle with the image moved into the middle of the word "Lorem": http://jsfiddle.net/timdown/qg5Qh/1/

It seems to be something to do with the styling applied to misspelled words. Add the word "Lorem" to the browser's dictionary and the image styling goes away.

You could switch spellchecking off using the spellcheck attribute. From what I can gather, you have to do this at the <body> level in Firefox because it doesn't seem to work on single contenteditable elements as it does for textareas.

Demo: http://jsfiddle.net/timdown/qg5Qh/2/

Community
  • 1
  • 1
Tim Down
  • 318,141
  • 75
  • 454
  • 536