Affected versions: 5.2.0+
Working versions: ≤ 5.1.0
Description
When scrollableContainer is set to a custom element (e.g. a wrapper div with position: relative), popups such as the link-edit popup render with an incorrect top value — typically a negative number that places the popup above the container's top edge instead of near the selection.
Root cause
In FroalaEditor.MODULES.position, the at(left, top, popup, height) function was changed in v5.2.0 to add a special case for position: relative containers:
// Step 1 — always runs:
t && (t -= c.offset().top)
// Step 2 — new in v5.2.0, runs when container is position:relative:
"relative" === c.css("position") && (
o = (r = c.get(0)).getBoundingClientRect(),
t = t && t - o.top + r.scrollTop
)
Both steps subtract the container's vertical position — offset().top (document-relative) and getBoundingClientRect().top (viewport-relative) — effectively double-subtracting and collapsing top to near zero.
v5.1.0 introduced the classList.contains("fr-toolbar") guard for the left offset (which is fine), but did not touch top.
v5.2.0 added the "relative" branch for top, which is the regression.
Fix
The t -= c.offset().top in Step 1 should be skipped (or Step 2 should be the only adjustment) for position: relative containers. The v4.x / v5.0.0 / v5.1.0 logic — a single t -= c.offset().top — was correct.
Affected versions: 5.2.0+
Working versions: ≤ 5.1.0
Description
When
scrollableContaineris set to a custom element (e.g. a wrapperdivwithposition: relative), popups such as the link-edit popup render with an incorrecttopvalue — typically a negative number that places the popup above the container's top edge instead of near the selection.Root cause
In
FroalaEditor.MODULES.position, theat(left, top, popup, height)function was changed in v5.2.0 to add a special case forposition: relativecontainers:Both steps subtract the container's vertical position —
offset().top(document-relative) andgetBoundingClientRect().top(viewport-relative) — effectively double-subtracting and collapsingtopto near zero.v5.1.0 introduced the
classList.contains("fr-toolbar")guard for theleftoffset (which is fine), but did not touchtop.v5.2.0 added the
"relative"branch fortop, which is the regression.Fix
The
t -= c.offset().topin Step 1 should be skipped (or Step 2 should be the only adjustment) forposition: relativecontainers. The v4.x / v5.0.0 / v5.1.0 logic — a singlet -= c.offset().top— was correct.