bito-code-review[bot] commented on code in PR #43472:
URL: https://github.com/apache/superset/pull/43472#discussion_r3845689894


##########
superset-frontend/packages/superset-ui-core/src/components/Table/utils/getScrollBarSize.ts:
##########
@@ -0,0 +1,59 @@
+/**
+ * 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.
+ */
+
+let cached: number | undefined;
+
+const css = (x: TemplateStringsArray) => x.join('\n');
+
+function measureScrollBarSize() {
+  const inner = document.createElement('div');
+  const outer = document.createElement('div');
+  inner.style.cssText = css`
+    width: auto;
+    height: 100%;
+    overflow: scroll;
+  `;
+  outer.style.cssText = css`
+    position: absolute;
+    visibility: hidden;
+    overflow: hidden;
+    width: 100px;
+    height: 50px;
+  `;
+  outer.append(inner);
+  document.body.append(outer);
+  const size = outer.clientWidth - inner.clientWidth;
+  outer.remove();
+  return size;
+}
+
+// Measures the browser/OS native scrollbar width. `VirtualTable`'s
+// react-window `Grid` body doesn't apply any custom `::-webkit-scrollbar`
+// styling, so its actual vertical scrollbar always renders at this native
+// size - used to keep the (separately rendered) header in sync with how
+// much horizontal space the scrollbar steals from the body's columns.
+export default function getScrollBarSize(forceRefresh = false) {
+  if (typeof document === 'undefined') {
+    return 0;
+  }
+  if (cached === undefined || forceRefresh) {
+    cached = measureScrollBarSize();
+  }
+  return cached;
+}

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Duplicate measureScrollBarSize logic</b></div>
   <div id="fix">
   
   Lines 20-58 (the entire implementation) are a semantic duplicate of 
`plugins/plugin-chart-table/src/DataTable/utils/getScrollBarSize.ts` (lines 
23-70). The only substantive difference is removal of the custom-scrollbar API. 
This duplication creates maintenance risk — both copies must stay in sync if 
`measureScrollBarSize` changes. The existing implementation already handles the 
non-custom case used by `VirtualTable`; the caller at line 171 of 
`VirtualTable.tsx` does not need custom scrollbar behavior. A single shared 
implementation (with re-export if needed) eliminates divergence risk.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #e49b9f</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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