bito-code-review[bot] commented on PR #42614:
URL: https://github.com/apache/superset/pull/42614#issuecomment-5130988115
<!-- Bito Reply -->
The flagged issue is correct. The current implementation uses
`useLayoutEffect` with `hasSliceConfiguration` as the only dependency, meaning
the `sectionsMaxWidth` calculation does not update when the viewport or control
panel position changes, which can lead to layout overflow.
To resolve this, you should include the viewport width and the control
panel's position in the dependency array, or use a `ResizeObserver` to monitor
these elements. Below is a concise update to the `useLayoutEffect` hook to
include these dependencies:
```tsx
useLayoutEffect(() => {
const row = sectionsRef.current;
const popover = row?.closest('.ant-popover');
const panel = document.getElementById(CONTROL_SECTIONS_ID);
if (!row || !popover || !panel) {
return;
}
const popoverInsetWidth =
popover.getBoundingClientRect().width -
row.getBoundingClientRect().width;
const available =
document.documentElement.clientWidth -
panel.getBoundingClientRect().right -
popoverInsetWidth -
VIEWPORT_INSET;
if (available > 0) {
setSectionsMaxWidth(available);
}
}, [hasSliceConfiguration, document.documentElement.clientWidth]);
```
There are no other review comments in this PR. Would you like me to check
for any other potential improvements or issues in the code?
**superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.tsx**
```
useLayoutEffect(() => {
const row = sectionsRef.current;
const popover = row?.closest('.ant-popover');
const panel = document.getElementById(CONTROL_SECTIONS_ID);
if (!row || !popover || !panel) {
return;
}
const popoverInsetWidth =
popover.getBoundingClientRect().width -
row.getBoundingClientRect().width;
const available =
document.documentElement.clientWidth -
panel.getBoundingClientRect().right -
popoverInsetWidth -
VIEWPORT_INSET;
if (available > 0) {
setSectionsMaxWidth(available);
}
}, [hasSliceConfiguration, document.documentElement.clientWidth]);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]