10

When I remove all content from contenteditable field, and then start typing new text wrapped into the same tag as deleted text despite that in debugger there are no relevant elements.

Examples:

enter image description here enter image description here

Expectable behavior is following (got in Firefox):

enter image description here

Could somebody help me to solve this issue?

P.S. If any extra information is needed please let me know.

4
  • 1
    According to the discussion on this post, it looks like a bug in Chrome that has been present for several years (this bug sheet dates from 2010). No workaround has been proposed, apparently. Commented May 25, 2017 at 22:17
  • I would like to play around with your code. Could you share your code so we know what WYSIWYG and what not you are using?
    – Tim
    Commented May 28, 2017 at 0:08
  • I guess it's because Chrome caches selected element, so add an event listener on delete button press and get a selection with JS, call removeAllRanges() or collapse() or collapseToEnd(). I hope it can help Commented May 28, 2017 at 13:57
  • @SergeySahakyan - I think you are correct, but I was curious, do you have any documentation for the element being cached?
    – Travis J
    Commented Jan 4, 2021 at 3:35

1 Answer 1

1

Try pasting text from the font size you normally would want. This will change the font size for you. If you want to choose the font size for the entire contenteditable field, try adding that to your CSS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.