mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
fix(frontend): Jupyter tab requires page refresh to display content (#9614)
This commit is contained in:
@@ -7,15 +7,36 @@ function Jupyter() {
|
||||
|
||||
// This is a hack to prevent the editor from overflowing
|
||||
// Should be removed after revising the parent and containers
|
||||
// Use ResizeObserver to properly track parent width changes
|
||||
React.useEffect(() => {
|
||||
let resizeObserver: ResizeObserver | null = null;
|
||||
|
||||
resizeObserver = new ResizeObserver((entries) => {
|
||||
for (const entry of entries) {
|
||||
// Use contentRect.width for more accurate measurements
|
||||
const { width } = entry.contentRect;
|
||||
if (width > 0) {
|
||||
setParentWidth(width);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (parentRef.current) {
|
||||
setParentWidth(parentRef.current.offsetWidth);
|
||||
resizeObserver.observe(parentRef.current);
|
||||
}
|
||||
|
||||
return () => {
|
||||
resizeObserver?.disconnect();
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Provide a fallback width to prevent the editor from being hidden
|
||||
// Use parentWidth if available, otherwise use a large default
|
||||
const maxWidth = parentWidth > 0 ? parentWidth : 9999;
|
||||
|
||||
return (
|
||||
<div ref={parentRef} className="h-full">
|
||||
<JupyterEditor maxWidth={parentWidth} />
|
||||
<JupyterEditor maxWidth={maxWidth} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user