fix: Only update scroll position when unmounting the editor#6420
Conversation
WalkthroughRemoved the CodeEditor internal scroll handler and its event binding/unbinding. componentWillUnmount now directly invokes the provided onScroll prop with the editor instance and removes the editor wrapper from the DOM. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (CODING_STANDARDS.md)
Files:
🧬 Code graph analysis (1)packages/bruno-app/src/components/CodeEditor/index.js (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
🔇 Additional comments (2)
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 |
b10ef5c to
feebb1c
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/bruno-app/src/components/CodeEditor/index.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
packages/bruno-app/src/components/CodeEditor/index.js
🧬 Code graph analysis (1)
packages/bruno-app/src/components/CodeEditor/index.js (1)
packages/bruno-app/src/utils/codemirror/lint-errors.js (1)
wrapper(86-86)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: SSL Tests - Linux
- GitHub Check: CLI Tests
- GitHub Check: Unit Tests
- GitHub Check: Playwright E2E Tests
- GitHub Check: SSL Tests - Windows
- GitHub Check: SSL Tests - macOS
🔇 Additional comments (1)
packages/bruno-app/src/components/CodeEditor/index.js (1)
285-286: Excellent cleanup implementation.The CodeMirror wrapper removal is properly implemented with optional chaining and matches the established pattern in the codebase. This cleanup is essential for preventing duplicate editors when React StrictMode remounts components during development.
before the scroll position was updatet on every scroll, causing everything related to the tab to rerender.
feebb1c to
44b9df6
Compare
Description
When scrolling, the
responsePaneScrollPositionwas updated on every frame, causing unnecessary re-renders of everything related to the tab, including the code editor itself. This caused performance issues and made scrolling look "sluggish".The scroll location is now only saved when needed (on unmount/navigation) rather than on every scroll event. The scroll position is still properly restored after sending a new request.
I also added proper cleanup for the CodeMirror instance. This prevents duplicate editors in development mode due to React StrictMode's double-rendering: https://react.dev/reference/react/StrictMode#fixing-bugs-found-by-double-rendering-in-development (Notice the doubled scrollbar in the before video)
Before
2025-12-16.00-27-03.mp4
After
2025-12-16.00-27-55.mp4
Notice in the "after" video, there are no red bars in the performance recording. These red bars indicate dropped frames.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.