Fixed Trailing whitespace after link, inside list with a child list evaporates in editor

Xon

Well-known member
Affected version
2.2.6 Patch 2
With the given bb-code;
Code:
[LIST]
[*][URL='http://example.com']example[/URL] example
[LIST]
[*]
[/LIST]
[/LIST]
ie;

Clicking edit while the rich text editor is enabled results in in this instead;

Stops happening without the (empty or not) child list.

Screenshot;
1627372348295.png
 

Xon

Well-known member
From the Html renderer (ie view);
HTML:
<ul>
<li data-xf-list-type="ul"><a href="http://example.com" target="_blank" class="link link--external" rel="noopener">example</a> example<ul>
<li data-xf-list-type="ul"></li>
</ul></li>
</ul>

From the EditorHtml renderer (ie edit);
HTML:
<ul>
<li data-xf-list-type="ul"><a href="http://example.com" target="_blank">example</a> example<ul>
<li data-xf-list-type="ul"></li>
</ul></li>
</ul><p></p>
 

Xon

Well-known member
This bug also exists in XF2.1

Adding this to EditorHtml is a super-hacky work-around.
PHP:
    protected function renderFinalListOutput($listType, array $elements)
    {
        $output = parent::renderFinalListOutput($listType, $elements);

        $output = \preg_replace_callback('/<\/a>(\s+)/i', function ($match) {
            return '</a>' . \str_repeat('&nbsp;', \utf8_strlen($match[1] ?? ''));
        }, $output);

        return $output;
    }
 
Top