I checked the issue with the current Sitecore.NET 9.3.0 (rev. 003498) without a hotfix mentioned by @Ed Lane (@ed-lane), and with the hotfix installed.
The behaviour still the same, the issue is not fixed, despite the fact that InlineEditingUtil.js was updated and contains a couple of improvements.
Only single-line text was checked & patched
The root cause: the P tag or DIV tag is added into empty input control, the tag depends on Sitecore setting
<setting name="HtmlEditor.LineBreak" value="p" />
How to simulate the issue
- empty any single-line text input control to get [No text in field] there
- add any text
- save the page
- P tag become visible, it was added into empty SPAN in this.checkEmptyEditableElement() method (or this.prepopulateEmptyElement() method in case of hotfix applied), see InlineEditingUtil.js for details
How to fix the issue - the original version
Open \sitecore\shell\Applications\Page Modes\InlineEditingUtil.js, this.checkEmptyEditableElement() method must be patched to avoid adding unwanted p tag into empty input:
this.checkEmptyEditableElement = function(target) {
...
// start of patch - the condition added
// to avoid adding unwanted p tag into empty single-line text input control
if (target.getAttribute("scfieldtype") !== "single-line text") {
// end of patch
var node = document.createElement(newLineNode);
range.insertNode(node);
range.collapse(true);
node.innerHTML = "<br />";
range.selectNodeContents(node);
selection.removeAllRanges();
selection.addRange(range);
// start of patch
}
// end of patch
...
};
How to fix the issue - version with hotfix
Open \sitecore\shell\Applications\Page Modes\InlineEditingUtil.js, this.prepopulateEmptyElement() and this.getClosestFieldNode() methods must be patched to avoid adding unwanted p tag into empty input:
this.prepopulateEmptyElement = function(target, fieldType) {
...
} else
// start of patch - the condition added
// to avoid adding unwanted p tag into empty single-line text input control
if (fieldType !== "single-line text")
// end of patch
{
var newLineNode = Sitecore.WebEditSettings.newLineBreak;
if (newLineNode.toLowerCase() == "p" || newLineNode.toLowerCase() == "div") {
var node = document.createElement(newLineNode);
range.insertNode(node);
range.collapse(true);
node.innerHTML = "<br />";
range.selectNodeContents(node);
selection.removeAllRanges();
selection.addRange(range);
}
}
...
};
this.getClosestFieldNode = function(currentNode) {
var result;
// start of patch - to select valid sitecore container
if (currentNode.nodeName == '#text')
{
currentNode = this.getClosestFieldNode(currentNode.parentElement);
}
// end of patch
if (currentNode.getAttribute("scfieldtype") != null ||
currentNode.tagName.localeCompare('body', 'en', { sensitivity: 'base' }) == 0) {
result = currentNode;
} else {
result = this.getClosestFieldNode(currentNode.parentElement);
}
return result;
};
the code before the patch applied:
