@micromag/core 0.3.19 → 0.3.20

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/es/components.js CHANGED
@@ -1045,12 +1045,27 @@ var Dropdown = function Dropdown(_ref) {
1045
1045
  onClickItem = _ref.onClickItem,
1046
1046
  onClickOutside = _ref.onClickOutside;
1047
1047
  var refContainer = useRef(null);
1048
+
1049
+ var _useState = useState(visible),
1050
+ _useState2 = _slicedToArray(_useState, 2),
1051
+ enabled = _useState2[0],
1052
+ setEnabled = _useState2[1];
1053
+
1048
1054
  var onDocumentClick = useCallback(function (e) {
1049
1055
  if (refContainer.current && !refContainer.current.contains(e.currentTarget) && onClickOutside !== null) {
1050
1056
  onClickOutside(e);
1051
1057
  }
1052
1058
  }, [refContainer.current, onClickOutside]);
1053
- useDocumentEvent('click', onDocumentClick, visible);
1059
+ useDocumentEvent('click', onDocumentClick, enabled); // Delay the outside click detection
1060
+
1061
+ useEffect(function () {
1062
+ var id = setTimeout(function () {
1063
+ setEnabled(visible);
1064
+ }, 100);
1065
+ return function () {
1066
+ clearTimeout(id);
1067
+ };
1068
+ }, [visible, setEnabled]);
1054
1069
  console.log('visible', visible); // eslint-disable-line
1055
1070
 
1056
1071
  return /*#__PURE__*/React.createElement("div", {
package/lib/components.js CHANGED
@@ -1068,12 +1068,27 @@ var Dropdown = function Dropdown(_ref) {
1068
1068
  onClickItem = _ref.onClickItem,
1069
1069
  onClickOutside = _ref.onClickOutside;
1070
1070
  var refContainer = React.useRef(null);
1071
+
1072
+ var _useState = React.useState(visible),
1073
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
1074
+ enabled = _useState2[0],
1075
+ setEnabled = _useState2[1];
1076
+
1071
1077
  var onDocumentClick = React.useCallback(function (e) {
1072
1078
  if (refContainer.current && !refContainer.current.contains(e.currentTarget) && onClickOutside !== null) {
1073
1079
  onClickOutside(e);
1074
1080
  }
1075
1081
  }, [refContainer.current, onClickOutside]);
1076
- hooks.useDocumentEvent('click', onDocumentClick, visible);
1082
+ hooks.useDocumentEvent('click', onDocumentClick, enabled); // Delay the outside click detection
1083
+
1084
+ React.useEffect(function () {
1085
+ var id = setTimeout(function () {
1086
+ setEnabled(visible);
1087
+ }, 100);
1088
+ return function () {
1089
+ clearTimeout(id);
1090
+ };
1091
+ }, [visible, setEnabled]);
1077
1092
  console.log('visible', visible); // eslint-disable-line
1078
1093
 
1079
1094
  return /*#__PURE__*/React__default["default"].createElement("div", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/core",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -132,5 +132,5 @@
132
132
  "publishConfig": {
133
133
  "access": "public"
134
134
  },
135
- "gitHead": "567326b79369a96c8c4cfed8ec08a3e67114261f"
135
+ "gitHead": "b7cde2045021ba116088cada89ff492e95634fee"
136
136
  }