I'm trying to use a contenteditable
span
. But if, as the user, I delete all the text within the span, the span disappears and is no longer editable (still in the DOM though). How do I prevent this?
I'm seeing this problem in both Chrome and FF.
Here's what I've tried:
<div class="subgroup" contenteditable="false" style="border: 1px solid red;">
<span class="header editable" contenteditable="true">initial contents</span>
</div>
I put contenteditable="false"
on the parent element based on this answer from 2015, but the result is the same whether or not that attribute is present on the parent.
Of course, I could have JS intercept keypresses to prevent the user from completely clearing the contents, but that's a bad UX. I'd much prefer a pure HTML solution in any event.