@atlaskit/renderer 133.10.6 → 133.11.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 133.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ba8c317b7b604`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ba8c317b7b604) -
8
+ Add breakout mark width and root-only panel/rule typing
9
+ - Updated dependencies
10
+
11
+ ## 133.11.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`d3536d2e15575`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d3536d2e15575) -
16
+ Fix inline comment anchoring to wrong text when a new selection is made while a draft is active.
17
+ Clears stale hover/selection draft position before promoting new selection, and adds missing deps
18
+ to useCallback arrays.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 133.10.6
4
25
 
5
26
  ### Patch Changes
@@ -60,7 +60,9 @@ var getWidth = function getWidth(width, mode) {
60
60
  * @returns The rendered breakout mark as a React element.
61
61
  */
62
62
  function Breakout(props) {
63
- var width = getWidth('width' in props ? props.width : null, props.mode);
63
+ var _props$width;
64
+ var breakoutWidth = (_props$width = props.width) !== null && _props$width !== void 0 ? _props$width : null;
65
+ var width = getWidth(breakoutWidth, props.mode);
64
66
  var useStickySafeCentering = (0, _expValEquals.expValEquals)('platform_editor_flex_based_centering', 'isEnabled', true);
65
67
  if (useStickySafeCentering) {
66
68
  return (0, _react.jsx)("div", {
@@ -96,7 +98,7 @@ function Breakout(props) {
96
98
  }, {
97
99
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
98
100
  style: {
99
- width: getWidth('width' in props ? props.width : null, props.mode)
101
+ width: width
100
102
  }
101
103
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
102
104
  ,
@@ -72,7 +72,7 @@ var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
72
72
  var TABLE_INFO_TIMEOUT = 10000;
73
73
  var RENDER_EVENT_SAMPLE_RATE = 0.1;
74
74
  var packageName = "@atlaskit/renderer";
75
- var packageVersion = "133.10.5";
75
+ var packageVersion = "133.11.0";
76
76
  var setAsQueryContainerStyles = (0, _react2.css)({
77
77
  containerName: 'ak-renderer-wrapper',
78
78
  containerType: 'inline-size'
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.Mounter = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
10
  var _adfSchema = require("@atlaskit/adf-schema");
10
11
  var _dom = require("../draft/dom");
11
12
  var _types = require("@atlaskit/analytics-listeners/types");
@@ -31,7 +32,9 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
31
32
  hoverDraftDocumentPosition = _useAnnotationRangeSt.hoverDraftDocumentPosition;
32
33
  var actions = (0, _react.useContext)(_RendererActionsContext.RendererContext);
33
34
  var onCreateCallback = (0, _react.useCallback)(function (annotationId) {
34
- var positionToAnnotate = hoverDraftDocumentPosition || documentPosition;
35
+ // Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
36
+ // in this closure may be stale (captured before state update) (COMMENTS-6594).
37
+ var positionToAnnotate = (0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
35
38
  if (!isAnnotationAllowed || !positionToAnnotate || !applyAnnotation) {
36
39
  return false;
37
40
  }
@@ -76,6 +79,13 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
76
79
  }
77
80
  return false;
78
81
  }
82
+
83
+ // Clear any stale draft position before promoting the new one.
84
+ // Without this, if a previous draft was not explicitly closed, hoverDraftDocumentPosition
85
+ // retains the old position and the comment anchors to the wrong text (COMMENTS-6594).
86
+ if ((0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
87
+ clearHoverDraft();
88
+ }
79
89
  promoteHoverToDraft(documentPosition);
80
90
  if (createAnalyticsEvent) {
81
91
  var uniqueAnnotationsInRange = actions.getAnnotationsByPosition(range);
@@ -99,7 +109,10 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
99
109
  }
100
110
  }
101
111
  });
102
- var positionToAnnotate = hoverDraftDocumentPosition || documentPosition;
112
+
113
+ // Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
114
+ // in this closure may be stale (captured before state update) (COMMENTS-6594).
115
+ var positionToAnnotate = (0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
103
116
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
104
117
  if (createAnalyticsEvent) {
105
118
  createAnalyticsEvent({
@@ -121,7 +134,7 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
121
134
  annotationType: _adfSchema.AnnotationTypes.INLINE_COMMENT
122
135
  };
123
136
  return applyAnnotation(positionToAnnotate, annotation);
124
- }, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft, hoverDraftDocumentPosition]);
137
+ }, [documentPosition, hoverDraftDocumentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft, clearHoverDraft]);
125
138
  var removeDraftModeCallback = (0, _react.useCallback)(function () {
126
139
  clearHoverDraft();
127
140
  var sel = window.getSelection();
@@ -7,9 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.SelectionInlineCommentMounter = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
12
  var _v = _interopRequireDefault(require("uuid/v4"));
11
13
  var _adfSchema = require("@atlaskit/adf-schema");
12
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _dom = require("../draft/dom");
14
15
  var _types = require("@atlaskit/analytics-listeners/types");
15
16
  var _analytics = require("@atlaskit/editor-common/analytics");
@@ -53,10 +54,9 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
53
54
  });
54
55
  }, [documentPosition, actions, range]);
55
56
  var onCreateCallback = (0, _react.useCallback)(function (annotationId) {
56
- // We want to support creation on a documentPosition if the user is only using ranges
57
- // but we want to prioritize draft positions if they are being used by consumers
58
- // !!! at this point, the documentPosition can be the wrong position if the user select something else
59
- var positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
57
+ // Use documentPosition directly when gate is on selectionDraftDocumentPosition may be stale
58
+ // (from a previous selection) causing the comment to anchor to the wrong text (COMMENTS-6594).
59
+ var positionToAnnotate = (0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
60
60
  if (!positionToAnnotate || !applyAnnotation) {
61
61
  return false;
62
62
  }
@@ -82,7 +82,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
82
82
  }).fire(_types.FabricChannel.editor);
83
83
  }
84
84
  return applyAnnotation(positionToAnnotate, annotation);
85
- }, [actions, documentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes, selectionDraftDocumentPosition]);
85
+ }, [actions, documentPosition, selectionDraftDocumentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes]);
86
86
  var createIndexCallback = (0, _react.useCallback)(function () {
87
87
  if (!documentPosition || !generateIndexMatch) {
88
88
  return false;
@@ -110,6 +110,11 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
110
110
  }
111
111
  return false;
112
112
  }
113
+
114
+ // Clear any stale draft position before promoting the new one (COMMENTS-6594).
115
+ if ((0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
116
+ clearSelectionDraft();
117
+ }
113
118
  promoteSelectionToDraft(documentPosition);
114
119
  if (createAnalyticsEvent) {
115
120
  var uniqueAnnotationsInRange = range ? actions.getAnnotationsByPosition(range) : [];
@@ -135,11 +140,11 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
135
140
  }
136
141
  });
137
142
 
138
- // at this point, the documentPosition is the position that the user has selected,
139
- // not the selectionDraftDocumentPosition
140
- // because the documentPosition is not promoted to selectionDraftDocumentPosition yet
141
- // use platform_editor_comments_api_manager here so we can clear the code path when the flag is removed
142
- var positionToAnnotate = (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager') ? documentPosition : selectionDraftDocumentPosition || documentPosition;
143
+ // Use documentPosition directly when either:
144
+ // - platform_editor_comments_api_manager is on (existing behaviour), OR
145
+ // - COMMENTS-6594 experiment is on (fix: avoids stale closure value)
146
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
147
+ var positionToAnnotate = (0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager') || (0, _expValEquals.expValEquals)('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
143
148
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
144
149
  if (createAnalyticsEvent) {
145
150
  createAnalyticsEvent({
@@ -161,7 +166,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
161
166
  annotationType: _adfSchema.AnnotationTypes.INLINE_COMMENT
162
167
  };
163
168
  return applyAnnotation(positionToAnnotate, annotation);
164
- }, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, selectionDraftDocumentPosition]);
169
+ }, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, clearSelectionDraft, selectionDraftDocumentPosition]);
165
170
  var removeDraftModeCallback = (0, _react.useCallback)(function () {
166
171
  clearSelectionDraft();
167
172
  var sel = window.getSelection();
@@ -53,7 +53,9 @@ const getWidth = (width, mode) => {
53
53
  * @returns The rendered breakout mark as a React element.
54
54
  */
55
55
  export default function Breakout(props) {
56
- const width = getWidth('width' in props ? props.width : null, props.mode);
56
+ var _props$width;
57
+ const breakoutWidth = (_props$width = props.width) !== null && _props$width !== void 0 ? _props$width : null;
58
+ const width = getWidth(breakoutWidth, props.mode);
57
59
  const useStickySafeCentering = expValEquals('platform_editor_flex_based_centering', 'isEnabled', true);
58
60
  if (useStickySafeCentering) {
59
61
  return jsx("div", {
@@ -89,7 +91,7 @@ export default function Breakout(props) {
89
91
  }, {
90
92
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
91
93
  style: {
92
- width: getWidth('width' in props ? props.width : null, props.mode)
94
+ width
93
95
  }
94
96
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
95
97
  ,
@@ -58,7 +58,7 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
58
58
  const TABLE_INFO_TIMEOUT = 10000;
59
59
  const RENDER_EVENT_SAMPLE_RATE = 0.1;
60
60
  const packageName = "@atlaskit/renderer";
61
- const packageVersion = "133.10.5";
61
+ const packageVersion = "133.11.0";
62
62
  const setAsQueryContainerStyles = css({
63
63
  containerName: 'ak-renderer-wrapper',
64
64
  containerType: 'inline-size'
@@ -1,4 +1,5 @@
1
1
  import React, { useCallback, useContext } from 'react';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  import { AnnotationTypes } from '@atlaskit/adf-schema';
3
4
  import { updateWindowSelectionAroundDraft } from '../draft/dom';
4
5
  import { FabricChannel } from '@atlaskit/analytics-listeners/types';
@@ -27,7 +28,9 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
27
28
  } = useAnnotationRangeState();
28
29
  const actions = useContext(ActionsContext);
29
30
  const onCreateCallback = useCallback(annotationId => {
30
- const positionToAnnotate = hoverDraftDocumentPosition || documentPosition;
31
+ // Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
32
+ // in this closure may be stale (captured before state update) (COMMENTS-6594).
33
+ const positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
31
34
  if (!isAnnotationAllowed || !positionToAnnotate || !applyAnnotation) {
32
35
  return false;
33
36
  }
@@ -72,6 +75,13 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
72
75
  }
73
76
  return false;
74
77
  }
78
+
79
+ // Clear any stale draft position before promoting the new one.
80
+ // Without this, if a previous draft was not explicitly closed, hoverDraftDocumentPosition
81
+ // retains the old position and the comment anchors to the wrong text (COMMENTS-6594).
82
+ if (expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
83
+ clearHoverDraft();
84
+ }
75
85
  promoteHoverToDraft(documentPosition);
76
86
  if (createAnalyticsEvent) {
77
87
  const uniqueAnnotationsInRange = actions.getAnnotationsByPosition(range);
@@ -95,7 +105,10 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
95
105
  }
96
106
  }
97
107
  });
98
- const positionToAnnotate = hoverDraftDocumentPosition || documentPosition;
108
+
109
+ // Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
110
+ // in this closure may be stale (captured before state update) (COMMENTS-6594).
111
+ const positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
99
112
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
100
113
  if (createAnalyticsEvent) {
101
114
  createAnalyticsEvent({
@@ -117,7 +130,7 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
117
130
  annotationType: AnnotationTypes.INLINE_COMMENT
118
131
  };
119
132
  return applyAnnotation(positionToAnnotate, annotation);
120
- }, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft, hoverDraftDocumentPosition]);
133
+ }, [documentPosition, hoverDraftDocumentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft, clearHoverDraft]);
121
134
  const removeDraftModeCallback = useCallback(() => {
122
135
  clearHoverDraft();
123
136
  const sel = window.getSelection();
@@ -1,9 +1,10 @@
1
1
  import React, { useCallback, useContext, useMemo, useEffect } from 'react';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
2
4
 
3
5
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
4
6
  import uuid from 'uuid/v4';
5
7
  import { AnnotationTypes, AnnotationMarkStates } from '@atlaskit/adf-schema';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { updateWindowSelectionAroundDraft } from '../draft/dom';
8
9
  import { FabricChannel } from '@atlaskit/analytics-listeners/types';
9
10
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
@@ -50,10 +51,9 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
50
51
  });
51
52
  }, [documentPosition, actions, range]);
52
53
  const onCreateCallback = useCallback(annotationId => {
53
- // We want to support creation on a documentPosition if the user is only using ranges
54
- // but we want to prioritize draft positions if they are being used by consumers
55
- // !!! at this point, the documentPosition can be the wrong position if the user select something else
56
- const positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
54
+ // Use documentPosition directly when gate is on selectionDraftDocumentPosition may be stale
55
+ // (from a previous selection) causing the comment to anchor to the wrong text (COMMENTS-6594).
56
+ const positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
57
57
  if (!positionToAnnotate || !applyAnnotation) {
58
58
  return false;
59
59
  }
@@ -79,7 +79,7 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
79
79
  }).fire(FabricChannel.editor);
80
80
  }
81
81
  return applyAnnotation(positionToAnnotate, annotation);
82
- }, [actions, documentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes, selectionDraftDocumentPosition]);
82
+ }, [actions, documentPosition, selectionDraftDocumentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes]);
83
83
  const createIndexCallback = useCallback(() => {
84
84
  if (!documentPosition || !generateIndexMatch) {
85
85
  return false;
@@ -107,6 +107,11 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
107
107
  }
108
108
  return false;
109
109
  }
110
+
111
+ // Clear any stale draft position before promoting the new one (COMMENTS-6594).
112
+ if (expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
113
+ clearSelectionDraft();
114
+ }
110
115
  promoteSelectionToDraft(documentPosition);
111
116
  if (createAnalyticsEvent) {
112
117
  const uniqueAnnotationsInRange = range ? actions.getAnnotationsByPosition(range) : [];
@@ -132,11 +137,11 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
132
137
  }
133
138
  });
134
139
 
135
- // at this point, the documentPosition is the position that the user has selected,
136
- // not the selectionDraftDocumentPosition
137
- // because the documentPosition is not promoted to selectionDraftDocumentPosition yet
138
- // use platform_editor_comments_api_manager here so we can clear the code path when the flag is removed
139
- const positionToAnnotate = fg('platform_editor_comments_api_manager') ? documentPosition : selectionDraftDocumentPosition || documentPosition;
140
+ // Use documentPosition directly when either:
141
+ // - platform_editor_comments_api_manager is on (existing behaviour), OR
142
+ // - COMMENTS-6594 experiment is on (fix: avoids stale closure value)
143
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
144
+ const positionToAnnotate = fg('platform_editor_comments_api_manager') || expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
140
145
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
141
146
  if (createAnalyticsEvent) {
142
147
  createAnalyticsEvent({
@@ -158,7 +163,7 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
158
163
  annotationType: AnnotationTypes.INLINE_COMMENT
159
164
  };
160
165
  return applyAnnotation(positionToAnnotate, annotation);
161
- }, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, selectionDraftDocumentPosition]);
166
+ }, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, clearSelectionDraft, selectionDraftDocumentPosition]);
162
167
  const removeDraftModeCallback = useCallback(() => {
163
168
  clearSelectionDraft();
164
169
  const sel = window.getSelection();
@@ -53,7 +53,9 @@ var getWidth = function getWidth(width, mode) {
53
53
  * @returns The rendered breakout mark as a React element.
54
54
  */
55
55
  export default function Breakout(props) {
56
- var width = getWidth('width' in props ? props.width : null, props.mode);
56
+ var _props$width;
57
+ var breakoutWidth = (_props$width = props.width) !== null && _props$width !== void 0 ? _props$width : null;
58
+ var width = getWidth(breakoutWidth, props.mode);
57
59
  var useStickySafeCentering = expValEquals('platform_editor_flex_based_centering', 'isEnabled', true);
58
60
  if (useStickySafeCentering) {
59
61
  return jsx("div", {
@@ -89,7 +91,7 @@ export default function Breakout(props) {
89
91
  }, {
90
92
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
91
93
  style: {
92
- width: getWidth('width' in props ? props.width : null, props.mode)
94
+ width: width
93
95
  }
94
96
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
95
97
  ,
@@ -63,7 +63,7 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
63
63
  var TABLE_INFO_TIMEOUT = 10000;
64
64
  var RENDER_EVENT_SAMPLE_RATE = 0.1;
65
65
  var packageName = "@atlaskit/renderer";
66
- var packageVersion = "133.10.5";
66
+ var packageVersion = "133.11.0";
67
67
  var setAsQueryContainerStyles = css({
68
68
  containerName: 'ak-renderer-wrapper',
69
69
  containerType: 'inline-size'
@@ -1,4 +1,5 @@
1
1
  import React, { useCallback, useContext } from 'react';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  import { AnnotationTypes } from '@atlaskit/adf-schema';
3
4
  import { updateWindowSelectionAroundDraft } from '../draft/dom';
4
5
  import { FabricChannel } from '@atlaskit/analytics-listeners/types';
@@ -23,7 +24,9 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
23
24
  hoverDraftDocumentPosition = _useAnnotationRangeSt.hoverDraftDocumentPosition;
24
25
  var actions = useContext(ActionsContext);
25
26
  var onCreateCallback = useCallback(function (annotationId) {
26
- var positionToAnnotate = hoverDraftDocumentPosition || documentPosition;
27
+ // Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
28
+ // in this closure may be stale (captured before state update) (COMMENTS-6594).
29
+ var positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
27
30
  if (!isAnnotationAllowed || !positionToAnnotate || !applyAnnotation) {
28
31
  return false;
29
32
  }
@@ -68,6 +71,13 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
68
71
  }
69
72
  return false;
70
73
  }
74
+
75
+ // Clear any stale draft position before promoting the new one.
76
+ // Without this, if a previous draft was not explicitly closed, hoverDraftDocumentPosition
77
+ // retains the old position and the comment anchors to the wrong text (COMMENTS-6594).
78
+ if (expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
79
+ clearHoverDraft();
80
+ }
71
81
  promoteHoverToDraft(documentPosition);
72
82
  if (createAnalyticsEvent) {
73
83
  var uniqueAnnotationsInRange = actions.getAnnotationsByPosition(range);
@@ -91,7 +101,10 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
91
101
  }
92
102
  }
93
103
  });
94
- var positionToAnnotate = hoverDraftDocumentPosition || documentPosition;
104
+
105
+ // Always use documentPosition directly when gate is on — hoverDraftDocumentPosition
106
+ // in this closure may be stale (captured before state update) (COMMENTS-6594).
107
+ var positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : hoverDraftDocumentPosition || documentPosition;
95
108
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
96
109
  if (createAnalyticsEvent) {
97
110
  createAnalyticsEvent({
@@ -113,7 +126,7 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
113
126
  annotationType: AnnotationTypes.INLINE_COMMENT
114
127
  };
115
128
  return applyAnnotation(positionToAnnotate, annotation);
116
- }, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft, hoverDraftDocumentPosition]);
129
+ }, [documentPosition, hoverDraftDocumentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, promoteHoverToDraft, clearHoverDraft]);
117
130
  var removeDraftModeCallback = useCallback(function () {
118
131
  clearHoverDraft();
119
132
  var sel = window.getSelection();
@@ -1,9 +1,10 @@
1
1
  import React, { useCallback, useContext, useMemo, useEffect } from 'react';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
2
4
 
3
5
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
4
6
  import uuid from 'uuid/v4';
5
7
  import { AnnotationTypes, AnnotationMarkStates } from '@atlaskit/adf-schema';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { updateWindowSelectionAroundDraft } from '../draft/dom';
8
9
  import { FabricChannel } from '@atlaskit/analytics-listeners/types';
9
10
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
@@ -44,10 +45,9 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
44
45
  });
45
46
  }, [documentPosition, actions, range]);
46
47
  var onCreateCallback = useCallback(function (annotationId) {
47
- // We want to support creation on a documentPosition if the user is only using ranges
48
- // but we want to prioritize draft positions if they are being used by consumers
49
- // !!! at this point, the documentPosition can be the wrong position if the user select something else
50
- var positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
48
+ // Use documentPosition directly when gate is on selectionDraftDocumentPosition may be stale
49
+ // (from a previous selection) causing the comment to anchor to the wrong text (COMMENTS-6594).
50
+ var positionToAnnotate = expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
51
51
  if (!positionToAnnotate || !applyAnnotation) {
52
52
  return false;
53
53
  }
@@ -73,7 +73,7 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
73
73
  }).fire(FabricChannel.editor);
74
74
  }
75
75
  return applyAnnotation(positionToAnnotate, annotation);
76
- }, [actions, documentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes, selectionDraftDocumentPosition]);
76
+ }, [actions, documentPosition, selectionDraftDocumentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes]);
77
77
  var createIndexCallback = useCallback(function () {
78
78
  if (!documentPosition || !generateIndexMatch) {
79
79
  return false;
@@ -101,6 +101,11 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
101
101
  }
102
102
  return false;
103
103
  }
104
+
105
+ // Clear any stale draft position before promoting the new one (COMMENTS-6594).
106
+ if (expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true)) {
107
+ clearSelectionDraft();
108
+ }
104
109
  promoteSelectionToDraft(documentPosition);
105
110
  if (createAnalyticsEvent) {
106
111
  var uniqueAnnotationsInRange = range ? actions.getAnnotationsByPosition(range) : [];
@@ -126,11 +131,11 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
126
131
  }
127
132
  });
128
133
 
129
- // at this point, the documentPosition is the position that the user has selected,
130
- // not the selectionDraftDocumentPosition
131
- // because the documentPosition is not promoted to selectionDraftDocumentPosition yet
132
- // use platform_editor_comments_api_manager here so we can clear the code path when the flag is removed
133
- var positionToAnnotate = fg('platform_editor_comments_api_manager') ? documentPosition : selectionDraftDocumentPosition || documentPosition;
134
+ // Use documentPosition directly when either:
135
+ // - platform_editor_comments_api_manager is on (existing behaviour), OR
136
+ // - COMMENTS-6594 experiment is on (fix: avoids stale closure value)
137
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
138
+ var positionToAnnotate = fg('platform_editor_comments_api_manager') || expValEquals('confluence_inline_comments_fix_stale_selection', 'isEnabled', true) ? documentPosition : selectionDraftDocumentPosition || documentPosition;
134
139
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
135
140
  if (createAnalyticsEvent) {
136
141
  createAnalyticsEvent({
@@ -152,7 +157,7 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
152
157
  annotationType: AnnotationTypes.INLINE_COMMENT
153
158
  };
154
159
  return applyAnnotation(positionToAnnotate, annotation);
155
- }, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, selectionDraftDocumentPosition]);
160
+ }, [documentPosition, isAnnotationAllowed, createAnalyticsEvent, applyAnnotation, actions, range, inlineNodeTypes, promoteSelectionToDraft, clearSelectionDraft, selectionDraftDocumentPosition]);
156
161
  var removeDraftModeCallback = useCallback(function () {
157
162
  clearSelectionDraft();
158
163
  var sel = window.getSelection();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "133.10.6",
3
+ "version": "133.11.1",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -67,7 +67,7 @@
67
67
  "@atlaskit/status": "^5.4.0",
68
68
  "@atlaskit/task-decision": "^21.4.0",
69
69
  "@atlaskit/theme": "^26.1.0",
70
- "@atlaskit/tmp-editor-statsig": "^126.0.0",
70
+ "@atlaskit/tmp-editor-statsig": "^126.1.0",
71
71
  "@atlaskit/tokens": "^15.8.0",
72
72
  "@atlaskit/tooltip": "^23.1.0",
73
73
  "@atlaskit/visually-hidden": "^4.1.0",
@@ -82,7 +82,7 @@
82
82
  "uuid": "^3.1.0"
83
83
  },
84
84
  "peerDependencies": {
85
- "@atlaskit/editor-common": "^116.30.0",
85
+ "@atlaskit/editor-common": "^116.32.0",
86
86
  "@atlaskit/link-provider": "^5.2.0",
87
87
  "@atlaskit/media-core": "^38.0.0",
88
88
  "react": "^18.2.0",
@@ -100,7 +100,7 @@
100
100
  "@atlaskit/media-core": "^38.0.0",
101
101
  "@atlaskit/media-integration-test-helpers": "workspace:^",
102
102
  "@atlaskit/media-test-helpers": "^42.2.0",
103
- "@atlaskit/mention": "^27.5.0",
103
+ "@atlaskit/mention": "^27.7.0",
104
104
  "@atlaskit/modal-dialog": "^16.1.0",
105
105
  "@atlaskit/navigation-system": "^10.5.0",
106
106
  "@atlaskit/profilecard": "^26.9.0",