msyavuz commented on code in PR #37022:
URL: https://github.com/apache/superset/pull/37022#discussion_r2711806127
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/tooltip.ts:
##########
@@ -47,20 +53,38 @@ export function getDefaultTooltip(refs: Refs) {
const divRect = refs.divRef?.current?.getBoundingClientRect();
// The mouse coordinates relative to the whole window
- // The first parameter to the position function is the mouse position
relative to the canvas
const mouseX = canvasMousePos[0] + (divRect?.x || 0);
const mouseY = canvasMousePos[1] + (divRect?.y || 0);
+ // Available viewport dimensions
+ const viewportWidth = document.documentElement.clientWidth;
+ const viewportHeight = document.documentElement.clientHeight;
+
// The width and height of the tooltip dom element
const tooltipWidth = sizes.contentSize[0];
const tooltipHeight = sizes.contentSize[1];
+ // Cap tooltip height to the smaller of 800px or 80vh
+ const maxAllowedHeight = Math.min(800, Math.floor(viewportHeight * 0.8));
+
+ if (tooltipDom) {
+ tooltipDom.style.maxHeight = `${maxAllowedHeight}px`;
+ tooltipDom.style.overflow = 'auto';
+ // mobile momentum scrolling
+ tooltipDom.style.setProperty('-webkit-overflow-scrolling', 'touch');
Review Comment:
This doesn't seem useful for now since we don't support mobile. I am ok with
it existing if it doesn't break anything else though
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/test/tooltip.test.ts:
##########
@@ -0,0 +1,68 @@
+/**
+ * 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.
+ */
+
+/** @jest-environment jsdom */
+import '@testing-library/jest-dom';
+import { getDefaultTooltip } from '../tooltip';
+import type { Refs } from '../../types';
+
+test('getDefaultTooltip computes height and sets scroll styles', () => {
+ const refs: Refs = {
+ divRef: {
+ current: {
+ getBoundingClientRect: () => ({ x: 0, y: 0, width: 100, height: 100 }),
+ },
+ },
+ } as unknown as Refs;
Review Comment:
Are there better types for this? Again, i don't think it's harmful if the
alternative is a huge object
--
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]