EnxDev commented on code in PR #42614:
URL: https://github.com/apache/superset/pull/42614#discussion_r3684532099


##########
superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.tsx:
##########
@@ -1010,6 +1082,66 @@ function AnnotationLayer({
     theme,
   ]);
 
+  const sliceConfiguration = renderSliceConfiguration();
+  const hasSliceConfiguration = !!sliceConfiguration;
+
+  const sectionGap = theme.sizeUnit * SECTION_GAP_UNITS;
+  const viewportInset = theme.sizeUnit * VIEWPORT_INSET_UNITS;
+
+  const measureSectionsMaxWidth = useCallback(() => {
+    const row = sectionsRef.current;
+    const popover = row?.closest('.ant-popover');
+    const panel = document.getElementById(CONTROL_SECTIONS_ID);

Review Comment:
   Added a comment on the early return to make the “no panel, no cap” case 
explicit.
   
   Regarding pure CSS: the viewport constraint is still handled in CSS as a 
fallback (`max-width: calc(100vw - 32px)`), but the remaining logic stays in JS 
for a few reasons:
   
   * The main cap is relative to the control panel's right edge, which is a 
draggable sibling in another subtree. Since the popover is portaled to 
`document.body`, CSS/container queries can't reference it.
   * The popover has additional chrome outside the row, so the available width 
is derived from the actual `popover.width - row.width` rather than hardcoding 
it.
   * We only apply the beside-panel cap when all sections can remain on one 
line. Wrapping significantly increases the popover height and can push the 
footer below the viewport, so this requires knowing the sections' intrinsic 
widths.
   
   The measurement intentionally uses the panel rather than the popover to 
avoid a feedback loop where each new cap affects the next measurement.
   
   For jank, the reads happen inside the `ResizeObserver` callback after 
layout, so there shouldn't be read/write thrashing. I haven't profiled it 
during an actual panel drag yet, though, so I'll verify that separately.
   



-- 
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]

Reply via email to