Editor: Align toolbar icon flickers on every keystroke in Edge (Froala align refresh replaces icon)

b1air

New member
Licensed customer
Affected version
2.3.13
XenForo version: 2.3.13
Browser: Microsoft Edge (current). Does not happen in Safari.

Steps to reproduce:
  1. Open any reply or new thread editor.
  2. Type in the editor.

Expected: toolbar icons stay still while typing.
Actual: the Align dropdown icon blinks on every key press.

Likely cause: Froala's align plugin refresh() (js/vendor/froala) runs on each toolbar refresh and always replaces the button's icon element, even when the alignment hasn't changed:
JavaScript:
c.find("> *").first().replaceWith(b.icon.create("align-" + alignment))

Suggested fix (untested): only swap the icon when the alignment changes, e.g.
JavaScript:
refresh: function ($btn) {
    var blocks = this.selection.blocks();
    if (!blocks.length) return;
    var alignment = this.helpers.getAlignment($(blocks[0]));
    if ($btn.data('xfAlign') === alignment) return;
    $btn.data('xfAlign', alignment);
    $btn.find('> *').first().replaceWith(this.icon.create('align-' + alignment));
}
 
Back
Top Bottom