@seeqdev/qomponents 0.0.107 → 0.0.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6604,27 +6604,40 @@ const QTip = () => {
6604
6604
  };
6605
6605
  }, []);
6606
6606
  const ttTimeout = React.useRef();
6607
+ const findTooltipData = (element) => {
6608
+ // Traverse up to 8 levels to find the tooltip data
6609
+ for (let i = 0; i < 8 && element; i++) {
6610
+ if (!element) {
6611
+ return null;
6612
+ }
6613
+ if (element?.dataset?.qtipText) {
6614
+ return element.dataset;
6615
+ }
6616
+ element = element?.parentElement;
6617
+ }
6618
+ return null;
6619
+ };
6607
6620
  const onMouseMove = (e) => {
6608
6621
  clearTimeout(ttTimeout.current);
6609
- tooltipTarget.current = e.target;
6610
- let dataset = e.target?.dataset;
6611
- let text = dataset?.qtipText;
6612
- // Buttons support React.Nodes as children, the tooltip however is applied to the actual button component.
6613
- // we only check two levels up - alternatively the tooltip can also be provided on the React.Node
6614
- if (!text || text === '') {
6615
- let currentTooltipTarget = e.target?.parentElement;
6616
- dataset = currentTooltipTarget?.dataset;
6617
- text = dataset?.qtipText;
6618
- if (!text || text === '') {
6619
- currentTooltipTarget = e.target?.parentElement?.parentElement || null;
6620
- dataset = currentTooltipTarget?.dataset;
6621
- text = dataset?.qtipText;
6622
- }
6623
- tooltipTarget.current = currentTooltipTarget;
6622
+ // Find tooltip data on the current or parent elements
6623
+ const target = e.target;
6624
+ const dataset = findTooltipData(target);
6625
+ if (!dataset) {
6626
+ // No tooltip data found
6627
+ tooltipTarget.current = null;
6628
+ return;
6624
6629
  }
6630
+ tooltipTarget.current = target;
6631
+ const text = dataset.qtipText;
6625
6632
  if (text) {
6626
- const delay = parseInt(dataset?.qtipDelay ?? DEFAULT_TOOL_TIP_DELAY + '');
6627
- ttTimeout.current = setTimeout(() => makeTooltip(text, dataset?.qtipPlacement, dataset?.qtipIsHtml === 'true', dataset?.qtipTestid, delay), delay);
6633
+ const delay = parseInt(dataset.qtipDelay || `${DEFAULT_TOOL_TIP_DELAY}`, 10);
6634
+ const placement = dataset.qtipPlacement || 'top';
6635
+ const isHtml = dataset.qtipIsHtml === 'true';
6636
+ const testId = dataset.qtipTestid;
6637
+ // Debounced tooltip display
6638
+ ttTimeout.current = setTimeout(() => {
6639
+ makeTooltip(text, placement, isHtml, testId, delay);
6640
+ }, delay);
6628
6641
  }
6629
6642
  };
6630
6643
  const makeTooltip = (tooltipText, position = 'top', isHtml, dataTestId, delay) => {