@contentful/field-editor-rich-text 4.20.7 → 4.20.8

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.
@@ -56,10 +56,15 @@ function _interop_require_wildcard(obj, nodeInterop) {
56
56
  const LinkPopover = ({ isLinkFocused, popoverText, handleEditLink, handleRemoveLink, children, handleCopyLink, isEditorFocused })=>{
57
57
  const popoverContent = _react.useRef(null);
58
58
  const [isPopoverContentClicked, setIsPopoverContentClicked] = _react.useState(false);
59
+ const isOpen = isLinkFocused && isEditorFocused || isPopoverContentClicked;
60
+ const isOpenRef = _react.useRef(false);
61
+ isOpenRef.current = isOpen;
59
62
  _react.useEffect(()=>{
60
63
  const handleMouseDown = (event)=>{
61
64
  if (popoverContent.current && popoverContent.current.contains(event.target)) {
62
- setIsPopoverContentClicked(true);
65
+ if (!isOpenRef.current) {
66
+ setIsPopoverContentClicked(true);
67
+ }
63
68
  } else {
64
69
  setIsPopoverContentClicked(false);
65
70
  }
@@ -69,7 +74,6 @@ const LinkPopover = ({ isLinkFocused, popoverText, handleEditLink, handleRemoveL
69
74
  document.removeEventListener('mousedown', handleMouseDown);
70
75
  };
71
76
  }, []);
72
- const isOpen = isLinkFocused && isEditorFocused || isPopoverContentClicked;
73
77
  const closePopover = ()=>{
74
78
  setIsPopoverContentClicked(false);
75
79
  };
@@ -83,6 +87,7 @@ const LinkPopover = ({ isLinkFocused, popoverText, handleEditLink, handleRemoveL
83
87
  className: _styles.styles.popover
84
88
  }, /*#__PURE__*/ _react.createElement(_f36components.Flex, {
85
89
  ref: popoverContent,
90
+ onMouseDownCapture: (e)=>e.preventDefault(),
86
91
  alignItems: "center",
87
92
  paddingTop: "spacing2Xs",
88
93
  paddingBottom: "spacing2Xs",
@@ -5,10 +5,15 @@ import { styles } from './styles';
5
5
  export const LinkPopover = ({ isLinkFocused, popoverText, handleEditLink, handleRemoveLink, children, handleCopyLink, isEditorFocused })=>{
6
6
  const popoverContent = React.useRef(null);
7
7
  const [isPopoverContentClicked, setIsPopoverContentClicked] = React.useState(false);
8
+ const isOpen = isLinkFocused && isEditorFocused || isPopoverContentClicked;
9
+ const isOpenRef = React.useRef(false);
10
+ isOpenRef.current = isOpen;
8
11
  React.useEffect(()=>{
9
12
  const handleMouseDown = (event)=>{
10
13
  if (popoverContent.current && popoverContent.current.contains(event.target)) {
11
- setIsPopoverContentClicked(true);
14
+ if (!isOpenRef.current) {
15
+ setIsPopoverContentClicked(true);
16
+ }
12
17
  } else {
13
18
  setIsPopoverContentClicked(false);
14
19
  }
@@ -18,7 +23,6 @@ export const LinkPopover = ({ isLinkFocused, popoverText, handleEditLink, handle
18
23
  document.removeEventListener('mousedown', handleMouseDown);
19
24
  };
20
25
  }, []);
21
- const isOpen = isLinkFocused && isEditorFocused || isPopoverContentClicked;
22
26
  const closePopover = ()=>{
23
27
  setIsPopoverContentClicked(false);
24
28
  };
@@ -32,6 +36,7 @@ export const LinkPopover = ({ isLinkFocused, popoverText, handleEditLink, handle
32
36
  className: styles.popover
33
37
  }, /*#__PURE__*/ React.createElement(Flex, {
34
38
  ref: popoverContent,
39
+ onMouseDownCapture: (e)=>e.preventDefault(),
35
40
  alignItems: "center",
36
41
  paddingTop: "spacing2Xs",
37
42
  paddingBottom: "spacing2Xs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "4.20.7",
3
+ "version": "4.20.8",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "registry": "https://npm.pkg.github.com/"
93
93
  },
94
- "gitHead": "0972539e3c1c1c95e43c948cb0a0827222d9cdd2"
94
+ "gitHead": "f171a049a7438ef245242b67813280023832582b"
95
95
  }