-
Notifications
You must be signed in to change notification settings - Fork 2
fix: use a MutationObserver for heightByRows #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe pull request updates the copyright year from 2024 to 2026 and refactors the height update mechanism in the grid helper connector from an event-based approach (listening to loading-changed events) to a MutationObserver-based approach that detects DOM mutations in the tbody element. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/resources/META-INF/frontend/fcGridHelper/connector.js (1)
56-83: Consider adding explicit cleanup for observers.Both the
ResizeObserverandMutationObserverare created but never explicitly cleaned up when the grid is destroyed. If grids are dynamically added and removed in your application, these observers will prevent garbage collection, leading to memory leaks.Consider adding a cleanup/destroy method to properly disconnect observers when the grid is no longer needed:
destroyHeightByRows: function() { if (grid.fcGridHelper._heightByRowsObserver) { grid.fcGridHelper._heightByRowsObserver.unobserve(grid); grid.fcGridHelper._heightByRowsObserver = null; } if (grid.fcGridHelper._heightByRowsMutationObserver) { grid.fcGridHelper._heightByRowsMutationObserver.disconnect(); grid.fcGridHelper._heightByRowsMutationObserver = null; } }This method should be called when the grid is detached or destroyed.
🤖 Fix all issues with AI agents
In @src/main/resources/META-INF/frontend/fcGridHelper/connector.js:
- Around line 81-82: The code calls
grid.fcGridHelper._heightByRowsMutationObserver.observe(tbody, ...) without
ensuring tbody exists, which can throw if tbody is null; update the block around
the query selector for "tbody#items" to check that tbody is non-null before
calling grid.fcGridHelper._heightByRowsMutationObserver.observe, and if null
either skip observing (or log a warning) so observe is only called when tbody is
present.
🧹 Nitpick comments (1)
src/main/resources/META-INF/frontend/fcGridHelper/connector.js (1)
72-79: LGTM: Efficient mutation handling.The MutationObserver correctly watches for
childListmutations and efficiently breaks after processing the first one. The approach of updating height on DOM mutations should be more reliable than event-based detection.If rapid mutations cause performance issues in the future, consider debouncing the
_updateHeightByRowscalls.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/resources/META-INF/frontend/fcGridHelper/connector.js
🔇 Additional comments (1)
src/main/resources/META-INF/frontend/fcGridHelper/connector.js (1)
68-70: LGTM: Proper observer cleanup.The code correctly disconnects any existing MutationObserver before creating a new one, preventing multiple observers from accumulating.



Close #163
Summary by CodeRabbit
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.