Skip to content

Commit 3a97b64

Browse files
javier-godoypaodb
authored andcommitted
fix: use a MutationObserver for heightByRows
Close #163
1 parent 961dbb1 commit 3a97b64

File tree

1 file changed

+15
-6
lines changed
  • src/main/resources/META-INF/frontend/fcGridHelper

1 file changed

+15
-6
lines changed

src/main/resources/META-INF/frontend/fcGridHelper/connector.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* Grid Helpers Add-on
44
* %%
5-
* Copyright (C) 2022 - 2024 Flowing Code
5+
* Copyright (C) 2022 - 2026 Flowing Code
66
* %%
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
@@ -64,13 +64,22 @@ import { Grid } from '@vaadin/grid/src/vaadin-grid.js';
6464

6565
grid.fcGridHelper._heightByRowsObserver.observe(grid);
6666

67-
grid.removeEventListener('loading-changed', grid.fcGridHelper._heightByRowsListener);
6867

69-
grid.fcGridHelper._heightByRowsListener = ()=>{
70-
if (!grid.loading) grid.fcGridHelper._updateHeightByRows(n);
71-
};
68+
if (grid.fcGridHelper._heightByRowsMutationObserver) {
69+
grid.fcGridHelper._heightByRowsMutationObserver.disconnect();
70+
}
71+
72+
grid.fcGridHelper._heightByRowsMutationObserver = new MutationObserver(mutationsList => {
73+
for (const mutation of mutationsList) {
74+
if (mutation.type === 'childList') {
75+
grid.fcGridHelper._updateHeightByRows(n);
76+
break;
77+
};
78+
}
79+
});
7280

73-
grid.addEventListener('loading-changed', grid.fcGridHelper._heightByRowsListener);
81+
let tbody = grid.shadowRoot.querySelector("tbody#items");
82+
grid.fcGridHelper._heightByRowsMutationObserver.observe(tbody, {childList: true});
7483
},
7584

7685
_updateHeightByRows : function(n) {

0 commit comments

Comments
 (0)