react-tooltip 4.2.14 → 4.2.18

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/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [4.2.18](https://github.com/wwayne/react-tooltip/compare/v4.2.17...v4.2.18) (2021-04-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **src/index.js:** add accessibility support for tabbing ([#695](https://github.com/wwayne/react-tooltip/issues/695)) ([ae936a5](https://github.com/wwayne/react-tooltip/commit/ae936a5))
7
+
8
+ ## [4.2.17](https://github.com/wwayne/react-tooltip/compare/v4.2.16...v4.2.17) (2021-03-26)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **type:** added role property to types ([#679](https://github.com/wwayne/react-tooltip/issues/679)) ([9b49395](https://github.com/wwayne/react-tooltip/commit/9b49395))
14
+
15
+ ## [4.2.16](https://github.com/wwayne/react-tooltip/compare/v4.2.15...v4.2.16) (2021-03-26)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **index.js:** fix exception when testing with Jest ([#682](https://github.com/wwayne/react-tooltip/issues/682)) ([f885f1f](https://github.com/wwayne/react-tooltip/commit/f885f1f))
21
+
22
+ ## [4.2.15](https://github.com/wwayne/react-tooltip/compare/v4.2.14...v4.2.15) (2021-02-26)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * do not delay show if tooltip is already shown ([#676](https://github.com/wwayne/react-tooltip/issues/676)) ([e8b9d84](https://github.com/wwayne/react-tooltip/commit/e8b9d84))
28
+
1
29
  ## [4.2.14](https://github.com/wwayne/react-tooltip/compare/v4.2.13...v4.2.14) (2021-02-16)
2
30
 
3
31
 
package/dist/index.es.js CHANGED
@@ -1171,6 +1171,7 @@ function (_React$Component) {
1171
1171
  var domRoot;
1172
1172
 
1173
1173
  switch (parentNode.constructor.name) {
1174
+ case 'Document':
1174
1175
  case 'HTMLDocument':
1175
1176
  domRoot = parentNode.head;
1176
1177
  break;
@@ -1283,12 +1284,14 @@ function (_React$Component) {
1283
1284
  }
1284
1285
 
1285
1286
  target.addEventListener('mouseenter', _this3.showTooltip, isCaptureMode);
1287
+ target.addEventListener('focus', _this3.showTooltip, isCaptureMode);
1286
1288
 
1287
1289
  if (effect === 'float') {
1288
1290
  target.addEventListener('mousemove', _this3.updateTooltip, isCaptureMode);
1289
1291
  }
1290
1292
 
1291
1293
  target.addEventListener('mouseleave', _this3.hideTooltip, isCaptureMode);
1294
+ target.addEventListener('blur', _this3.showTooltip, isCaptureMode);
1292
1295
  });
1293
1296
  } // Global event to hide tooltip
1294
1297
 
@@ -1402,6 +1405,11 @@ function (_React$Component) {
1402
1405
  scrollHide = e.currentTarget.getAttribute('data-scroll-hide') === 'true';
1403
1406
  } else if (this.props.scrollHide != null) {
1404
1407
  scrollHide = this.props.scrollHide;
1408
+ } // adding aria-describedby to target to make tooltips read by screen readers
1409
+
1410
+
1411
+ if (e && e.currentTarget && e.currentTarget.setAttribute) {
1412
+ e.currentTarget.setAttribute('aria-describedby', this.state.uuid);
1405
1413
  } // Make sure the correct place is set
1406
1414
 
1407
1415
 
@@ -1488,7 +1496,6 @@ function (_React$Component) {
1488
1496
  disable = _this$state.disable;
1489
1497
  var afterShow = this.props.afterShow;
1490
1498
  var placeholder = this.getTooltipContent();
1491
- var delayTime = parseInt(delayShow, 10);
1492
1499
  var eventTarget = e.currentTarget || e.target; // Check if the mouse is actually over the tooltip, if so don't hide the tooltip
1493
1500
 
1494
1501
  if (this.mouseOnToolTip()) {
@@ -1500,6 +1507,8 @@ function (_React$Component) {
1500
1507
  return;
1501
1508
  }
1502
1509
 
1510
+ var delayTime = !this.state.show ? parseInt(delayShow, 10) : 0;
1511
+
1503
1512
  var updateState = function updateState() {
1504
1513
  if (Array.isArray(placeholder) && placeholder.length > 0 || placeholder) {
1505
1514
  var isInvisible = !_this5.state.show;
@@ -1520,7 +1529,7 @@ function (_React$Component) {
1520
1529
 
1521
1530
  clearTimeout(this.delayShowLoop);
1522
1531
 
1523
- if (delayShow) {
1532
+ if (delayTime) {
1524
1533
  this.delayShowLoop = setTimeout(updateState, delayTime);
1525
1534
  } else {
1526
1535
  updateState();
@@ -1575,6 +1584,11 @@ function (_React$Component) {
1575
1584
  return ele === e.currentTarget;
1576
1585
  });
1577
1586
  if (!isMyElement || !this.state.show) return;
1587
+ } // clean up aria-describedby when hiding tooltip
1588
+
1589
+
1590
+ if (e && e.currentTarget && e.currentTarget.removeAttribute) {
1591
+ e.currentTarget.removeAttribute('aria-describedby');
1578
1592
  }
1579
1593
 
1580
1594
  var resetState = function resetState() {
@@ -1696,7 +1710,8 @@ function (_React$Component) {
1696
1710
  extraClass = _this$state3.extraClass,
1697
1711
  html = _this$state3.html,
1698
1712
  ariaProps = _this$state3.ariaProps,
1699
- disable = _this$state3.disable;
1713
+ disable = _this$state3.disable,
1714
+ uuid = _this$state3.uuid;
1700
1715
  var content = this.getTooltipContent();
1701
1716
  var isEmptyTip = this.isEmptyTip(content);
1702
1717
  var style = generateTooltipStyle(this.state.uuid, this.state.customColors, this.state.type, this.state.border);
@@ -1715,7 +1730,7 @@ function (_React$Component) {
1715
1730
  var htmlContent = "".concat(content, "\n<style>").concat(style, "</style>");
1716
1731
  return React.createElement(Wrapper, _extends({
1717
1732
  className: "".concat(wrapperClassName),
1718
- id: this.props.id,
1733
+ id: this.props.id || uuid,
1719
1734
  ref: function ref(_ref) {
1720
1735
  return _this9.tooltipRef = _ref;
1721
1736
  }
@@ -1728,7 +1743,7 @@ function (_React$Component) {
1728
1743
  } else {
1729
1744
  return React.createElement(Wrapper, _extends({
1730
1745
  className: "".concat(wrapperClassName),
1731
- id: this.props.id
1746
+ id: this.props.id || uuid
1732
1747
  }, ariaProps, {
1733
1748
  ref: function ref(_ref2) {
1734
1749
  return _this9.tooltipRef = _ref2;