fix: soup crashing safari at certain widths#2580
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughOptimized header collapse behavior in the split-layout component by introducing debounced evaluation scheduling via Changes
🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@js/app/packages/app/component/split-layout/utils/createHeaderCollapser.ts`:
- Around line 65-68: In createHeaderCollapser the ResizeObserver instance
(observer) is only attached once to the initial header element and never
re-attached if getContainer() later returns a new node; update the logic so
whenever headerLeft is resolved you call observer.observe(headerLeft) (and if
the resolved element differs from the previously-observed node, call
observer.unobserve(prev) or observer.disconnect() first) and ensure you store
the currentlyObserved element so future container swaps rebind the observer;
keep using scheduleEvaluate as the callback and also disconnect the observer
during cleanup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8d099b60-c5db-4aa3-886b-39add09b8e7b
📒 Files selected for processing (1)
js/app/packages/app/component/split-layout/utils/createHeaderCollapser.ts
| if (!observer) { | ||
| observer = new ResizeObserver(() => queueMicrotask(evaluate)); | ||
| observer = new ResizeObserver(() => scheduleEvaluate()); | ||
| observer.observe(headerLeft); | ||
| } |
There was a problem hiding this comment.
ResizeObserver stays bound to the first container instance.
If getContainer() later points to a new element, that new node is never observed, so collapse logic can silently stop reacting to resizes.
Proposed fix
let observer: ResizeObserver | null = null;
+let observedContainer: HTMLElement | null = null;
const evaluate = () => {
const headerLeft = getContainer();
if (!headerLeft) return;
- if (!observer) {
- observer = new ResizeObserver(() => scheduleEvaluate());
- observer.observe(headerLeft);
- }
+ if (!observer) {
+ observer = new ResizeObserver(() => scheduleEvaluate());
+ }
+ if (observedContainer !== headerLeft) {
+ if (observedContainer) observer.unobserve(observedContainer);
+ observer.observe(headerLeft);
+ observedContainer = headerLeft;
+ }
...
};
onCleanup(() => {
observer?.disconnect();
+ observedContainer = null;
if (rafId !== null) cancelAnimationFrame(rafId);
});🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@js/app/packages/app/component/split-layout/utils/createHeaderCollapser.ts`
around lines 65 - 68, In createHeaderCollapser the ResizeObserver instance
(observer) is only attached once to the initial header element and never
re-attached if getContainer() later returns a new node; update the logic so
whenever headerLeft is resolved you call observer.observe(headerLeft) (and if
the resolved element differs from the previously-observed node, call
observer.unobserve(prev) or observer.disconnect() first) and ensure you store
the currentlyObserved element so future container swaps rebind the observer;
keep using scheduleEvaluate as the callback and also disconnect the observer
during cleanup.
No description provided.