Skip to content

Commit 91f1184

Browse files
committed
BUGFIX: Prevent delayed repositioning of toolbars during inline editing
Before it would take some time during editing when newlines are added until the anchorposition would be recalculated due to the stored node change.
1 parent 40611b5 commit 91f1184

File tree

1 file changed

+9
-1
lines changed
  • packages/neos-ui-guest-frame/src/InlineUI/NodeToolbar

1 file changed

+9
-1
lines changed

packages/neos-ui-guest-frame/src/InlineUI/NodeToolbar/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,23 @@ const NodeToolbar: React.FC<NodeToolbarProps> = ({
162162
iframeWindow.addEventListener('load', debouncedUpdateRef.current);
163163
iframeWindow.addEventListener('mousemove', handleMouseMove);
164164

165+
// With the observer we can immediately react to size changes during inline editing
166+
const resizeObserver = new ResizeObserver(updateAnchorPosition);
167+
const nodeElement = findNodeInGuestFrame(contextPath, fusionPath);
168+
if (nodeElement) {
169+
resizeObserver.observe(nodeElement);
170+
}
171+
165172
scrollIntoView();
166173
updateAnchorPosition();
167174

168175
return () => {
176+
resizeObserver.disconnect();
169177
iframeWindow.removeEventListener('resize', debouncedUpdateRef.current);
170178
iframeWindow.removeEventListener('load', debouncedUpdateRef.current);
171179
iframeWindow.removeEventListener('mousemove', handleMouseMove);
172180
};
173-
}, [handleMouseMove, scrollIntoView, updateAnchorPosition]);
181+
}, [contextPath, fusionPath, handleMouseMove, scrollIntoView, updateAnchorPosition]);
174182

175183
// Update effect - equivalent to componentDidUpdate
176184
useEffect(() => {

0 commit comments

Comments
 (0)