Skip to content

Commit b70cc64

Browse files
[FIX] web: NO SQUASH, position and scrolling issue
[FIX] html_editor (position and scrolling issue) DO NOT SQUASH: very specific fix for overlay_buttons_plugin move on scroll
1 parent ac086d8 commit b70cc64

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

addons/html_editor/static/src/core/overlay_plugin.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { markRaw, EventBus } from "@odoo/owl";
22
import { Plugin } from "../plugin";
33
import { EditorOverlay } from "./overlay";
44
import { throttleForAnimation } from "@web/core/utils/timing";
5-
import { findUpTo } from "@html_editor/utils/dom_traversal";
5+
import { closestScrollableY } from "@web/core/utils/scrolling";
66

77
/**
88
* @typedef { Object } OverlayShared
@@ -56,14 +56,7 @@ export class OverlayPlugin extends Plugin {
5656
}
5757

5858
getScrollContainer() {
59-
const isScrollable = (element) =>
60-
element.scrollHeight > element.clientHeight &&
61-
["auto", "scroll"].includes(getComputedStyle(element).overflowY);
62-
63-
return (
64-
findUpTo(this.iframe || this.editable, null, isScrollable) ||
65-
this.topDocument.documentElement
66-
);
59+
return closestScrollableY(this.iframe || this.editable) || this.topDocument.documentElement;
6760
}
6861
}
6962

addons/web/static/src/core/position/position_hook.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,15 @@ export function usePosition(refName, getTarget, options = {}) {
9797
const targetDocument = getTarget()?.ownerDocument;
9898
targetDocument?.addEventListener("scroll", scrollListener, { capture: true });
9999
targetDocument?.addEventListener("load", throttledUpdate, { capture: true });
100+
const containerDocument = options.container?.()?.ownerDocument;
101+
containerDocument?.addEventListener("scroll", scrollListener, { capture: true });
102+
containerDocument?.addEventListener("load", throttledUpdate, { capture: true });
100103
window.addEventListener("resize", throttledUpdate);
101104
return () => {
102105
targetDocument?.removeEventListener("scroll", scrollListener, { capture: true });
103106
targetDocument?.removeEventListener("load", throttledUpdate, { capture: true });
107+
containerDocument?.removeEventListener("scroll", scrollListener, { capture: true });
108+
containerDocument?.removeEventListener("load", throttledUpdate, { capture: true });
104109
window.removeEventListener("resize", throttledUpdate);
105110
};
106111
}

0 commit comments

Comments
 (0)