@pushwoosh/dumb-components 4.17.0 → 4.17.1

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.
@@ -1,7 +1,7 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import type { TooltipProps } from './types';
3
3
  /**
4
- * Wraps an element and shows a contextual tooltip on hover/focus, with configurable
4
+ * Wraps an element and shows a contextual tooltip on hover/keyboard focus, with configurable
5
5
  * position, width and color. Positioning is handled by floating-ui, so the tooltip
6
6
  * flips to a fallback placement when the requested one would overflow the viewport. Use
7
7
  * {@link TooltipTrigger} for a standalone help icon.
@@ -6,7 +6,7 @@ import { DEFAULT_MAX_WIDTH } from './constants';
6
6
  import { Arrow, TooltipBox } from './styles';
7
7
  import { useTooltipPosition } from './useTooltipPosition';
8
8
  /**
9
- * Wraps an element and shows a contextual tooltip on hover/focus, with configurable
9
+ * Wraps an element and shows a contextual tooltip on hover/keyboard focus, with configurable
10
10
  * position, width and color. Positioning is handled by floating-ui, so the tooltip
11
11
  * flips to a fallback placement when the requested one would overflow the viewport. Use
12
12
  * {@link TooltipTrigger} for a standalone help icon.
@@ -70,14 +70,19 @@ export function Tooltip({
70
70
  }
71
71
  const show = () => setIsHovered(true);
72
72
  const hide = () => setIsHovered(false);
73
+ const showOnKeyboardFocus = event => {
74
+ if (event.target instanceof Element && event.target.matches(':focus-visible')) {
75
+ show();
76
+ }
77
+ };
73
78
  referenceEl.addEventListener('mouseenter', show);
74
79
  referenceEl.addEventListener('mouseleave', hide);
75
- referenceEl.addEventListener('focusin', show);
80
+ referenceEl.addEventListener('focusin', showOnKeyboardFocus);
76
81
  referenceEl.addEventListener('focusout', hide);
77
82
  return () => {
78
83
  referenceEl.removeEventListener('mouseenter', show);
79
84
  referenceEl.removeEventListener('mouseleave', hide);
80
- referenceEl.removeEventListener('focusin', show);
85
+ referenceEl.removeEventListener('focusin', showOnKeyboardFocus);
81
86
  referenceEl.removeEventListener('focusout', hide);
82
87
  };
83
88
  }, [referenceEl, isControlled]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "4.17.0",
3
+ "version": "4.17.1",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",