syncContainerResizeObserverTarget method
void
syncContainerResizeObserverTarget()
Points the observer at the element that currently carries the width.
Not the host: li-datatable is a custom element with no display of its
own, so it computes to inline, and a ResizeObserver reports nothing
for a non-replaced inline box -- it would sit there silent. The scroll
container is block-level and is the very element
_measureResponsiveAvailableWidth reads.
It also changes identity: *ngIf swaps table and grid viewports, so this
runs after every draw and re-points the observer when the target moved.
Implementation
void syncContainerResizeObserverTarget() {
final observer = _containerResizeObserver;
if (observer == null) {
return;
}
final target = scrollContainer ?? gridScrollContainer;
if (identical(target, _observedResizeTarget)) {
return;
}
final previousTarget = _observedResizeTarget;
if (previousTarget != null) {
observer.unobserve(previousTarget);
}
_observedResizeTarget = target;
if (target != null) {
observer.observe(target);
}
}