The Behavior
- When you first time click on the control, the outer div is getting focused. You can change its size by dragging any white dots at its edges. This is
contenteditable=true
expected to do.
- When you double click on the click, the div leaves edit mode and the input control gets focused. So you are able to enter text.
Both are expected behaviors of (Microsoft) HTML document elements.
The Solutions
- If you can remove the attribute, your web page will behave same in all browsers.
- If you cannot remove the attribute, you can put a switch to toggle editable state. Here is my tiny code example:
<div id="ctrl" contenteditable="true">
<input type="text" />
</div>
<div id="buttonGroup">
<span>This affects to MSIE only</span>
<button onclick="document.getElementById('ctrl').contentEditable='false'">Disable editable</button>
<button onclick="document.getElementById('ctrl').contentEditable='true'">Enable editable</button>
</div>
Update 1:
If you cannot remove the attribute and want to keep resize gripper around the div, you can listen the onfocus event of the outer div and set focus to inner input control.
var divElem = document.querySelector("div[contenteditable='true']");
divElem.onfocus = function() {
divElem.querySelector('input').focus();
}