Multi-Line field bugs in Sitecore 8.1
If you’re using Multi-Line fields in Sitecore, as of Sitecore 8.1 Update 1 you will encounter problems with using them when editing content in the Experience Editor.
These two bugs are:
- When you create a new line in the field, the Experience Editor will actually add two new line breaks instead of one.
- When you save, all lines except for the first are not saved.
Here is a demo illustrating both issues:
Both of these issues have been reported to Sitecore Support. Here’s a bit more information on each:
This bug is down to the
FieldChromeType.js file used in the front-end to provide the editing functionality for the fields. It is incorrectly adding in two
<br> tags into the HTML when a new-line is created.
This issue has been reported to Sitecore Support and has been confirmed as a bug. If you have need to reference this bug in a support ticket with Sitecore, the public reference number is 103584.
Sitecore Support have supplied an updated version of the JS file that fixes the issue. You can get this file from Support if you reference the above number, also if you log this issue it will help inform Sitecore of how wide-affecting the issue is.
I have also hosted the file here on this site for your convenience. By using this file you accept responsibility for doing so, and I strongly recommend you compare this file to the one you are replacing in your solution to confirm what you are changing, as well as still reporting to Sitecore Support that you encountered the bug.
To apply the fix, just place the updated file in
\sitecore\shell\Applications\Page Modes\ChromeTypes, replacing the existing file.
Note that this fix is for 8.1 Update 1 and Update 2 only.
In Sitecore 8.1 Update 1, the
Sitecore.ExperienceEditor.WebUtilty class was updated to amend the regex that is used to process fields before they are saved. Unfortunately, the new regex in place is too hungry and matches across all
<br> tags, removing them along with all the content inbetween. The result is that only the first line remains.
This issue has been reported to Sitecore Support and has been confirmed as a bug. If you are looking for information on this bug, the public reference number is 101295. This problem also affects the recently released Update 2.
WebUtility class is static and as such it’s not trivial to implement a replacement for this class. There are no references to it in configuration allowing it to be swapped out with an alternative.
The workaround suggestion by Support at the moment is to use a Rich-Text field.
Alternatively, and the route we have gone, is to remove the ability to edit this field in the Experience Editor and to have our users make the update to this field in the Content Editor. As this was just a single field that is only used on a handful of items, that worked well enough for us. However, if you make extensive use of the Multi-Line field and Experience Editor, you may need to investigate a more robust workaround. If you have done this, please comment below!
Kayee has written a blog post on a very similar bug that also effects the Multi-Line field in the Experience Editor, though in that scenario it’s if you are using it combined with a Custom Experience Button.
Fortunately, that bug has fix available for it. You can see a demo of the bug and get the fix from the link below.