Skip to content

Conversation

@javier-godoy
Copy link
Member

@javier-godoy javier-godoy commented Jan 7, 2026

Close #163

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced the grid component's height adjustment mechanism to more reliably respond to content changes, ensuring proper layout rendering when data is dynamically added or removed.
  • Chores

    • Updated copyright year to 2026.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

Walkthrough

The 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

Cohort / File(s) Summary
Grid Height Update Mechanism
src/main/resources/META-INF/frontend/fcGridHelper/connector.js
Replaced loading-changed event listener with MutationObserver observing tbody#items for childList mutations; updated copyright year to 2026; refactored initialization to call _updateHeightByRows when DOM mutations occur rather than on grid-level events

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • mlopezFC
  • paodb
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: replacing an event-based approach with a MutationObserver for the heightByRows feature.
Linked Issues check ✅ Passed The PR addresses issue #163 by implementing a MutationObserver-based approach for heightByRows, which should resolve the integration test failure where expected value was 10 but observed was 9.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the heightByRows behavior. Only copyright year bump and MutationObserver implementation in connector.js are present, both directly related to issue #163.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2026

Copy link

@coderabbitai coderabbitai bot left a 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 ResizeObserver and MutationObserver are 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 childList mutations 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 _updateHeightByRows calls.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 961dbb1 and bbdb901.

📒 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.

@javier-godoy javier-godoy requested review from mlopezFC and paodb January 8, 2026 12:26
@paodb paodb merged commit 3a97b64 into master Jan 8, 2026
5 checks passed
@paodb paodb deleted the fix-163 branch January 8, 2026 12:30
@github-project-automation github-project-automation bot moved this from To Do to Pending release in Flowing Code Addons Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending release

Development

Successfully merging this pull request may close these issues.

Vaadin 24: HeightByRowsIT integration tests fail (testOpenWithItemsDefaultSize)

3 participants