Copilot commented on code in PR #68750:
URL: https://github.com/apache/airflow/pull/68750#discussion_r3518827703


##########
airflow/www/jest-globals-setup.js:
##########
@@ -45,6 +45,17 @@ if (typeof globalThis.window !== "undefined" && 
!globalThis.window.matchMedia) {
   };
 }
 
+// Mock ResizeObserver (not implemented in jsdom) — used by useContentHeight
+if (typeof globalThis.ResizeObserver === "undefined") {
+  globalThis.ResizeObserver = function ResizeObserver() {
+    return {
+      observe() {},
+      unobserve() {},
+      disconnect() {},
+    };
+  };
+}

Review Comment:
   The ResizeObserver mock returns a plain object from the constructor. That 
makes `new ResizeObserver(...) instanceof ResizeObserver` false and diverges 
from the real API shape, which can break tests (or libraries) that rely on 
constructor/class semantics. Use a class-style mock that accepts the callback 
parameter and provides methods on the instance.



##########
airflow/www/static/js/utils/useContentHeight.ts:
##########
@@ -0,0 +1,61 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React, { useLayoutEffect, useState } from "react";
+
+// Vertical space available to a scroll container: from where the element 
actually sits in the page
+// down to the body's bottom padding (the Flask footer reserve). Anchoring to 
the viewport this way
+// avoids the `height: 100%` cascade, which over-claims because 
<Tabs>/<TabPanel> have sibling chrome
+// (tab headers) on top — that cascade is what truncated the details tabs.
+const useContentHeight = (contentRef: React.RefObject<HTMLElement>) => {
+  const [height, setHeight] = useState(0);
+
+  useLayoutEffect(() => {
+    const update = () => {
+      const element = contentRef.current;
+      if (!element) return;
+      const footerReserve =
+        parseInt(
+          getComputedStyle(document.body).paddingBottom.replace("px", ""),
+          10,
+        ) || 0;

Review Comment:
   `getComputedStyle(...).paddingBottom` is already a CSS length string like 
"16px". Using `parseFloat(...)` avoids the extra `.replace("px", "")` and is 
more robust if the string format ever changes (e.g. extra whitespace).



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

Reply via email to