@atlaskit/pragmatic-drag-and-drop 1.1.4 → 1.1.6

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,17 @@
1
1
  # @atlaskit/pragmatic-drag-and-drop
2
2
 
3
+ ## 1.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#94759](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94759) [`140fc0d20c02`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/140fc0d20c02) - Fixing our Safari workaround in `setCustomNativeDragPreview()` for a [Safari drag preview bug](https://bugs.webkit.org/show_bug.cgi?id=266025) so that it works correctly for `react@18+` usage.
8
+
9
+ ## 1.1.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#94316](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94316) [`35fd5ed8e1d7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/35fd5ed8e1d7) - Upgrading internal dependency `bind-event-listener` to `@^3.0.0`
14
+
3
15
  ## 1.1.4
4
16
 
5
17
  ### Patch Changes
@@ -81,6 +81,7 @@ function setCustomNativeDragPreview(_ref) {
81
81
  * On `Safari@17.1` if a drag preview element has some opacity,
82
82
  * Safari will include elements behind the drag preview element
83
83
  * in the drag preview.
84
+ * Bug: https://bugs.webkit.org/show_bug.cgi?id=266025
84
85
  *
85
86
  * **Fix**
86
87
  * We push the drag preview so it is _almost_ completely offscreen so that
@@ -98,8 +99,23 @@ function setCustomNativeDragPreview(_ref) {
98
99
  * → Wrecks the opacity of the drag preview element
99
100
  */
100
101
  if ((0, _isSafari.isSafari)()) {
101
- var rect = container.getBoundingClientRect();
102
- container.style.left = "-".concat(rect.width - 0.0001, "px");
102
+ /**
103
+ * For some frameworks (eg `react@18+` with `ReactDOM.createRoot().render()`) the rendering
104
+ * inside the `container` does not occur until after a microtask.
105
+ *
106
+ * Notes:
107
+ * - This will run before the browser takes it's picture of the element
108
+ * - This will run before the animation frame that removes `container`.
109
+ **/
110
+ queueMicrotask(function () {
111
+ var rect = container.getBoundingClientRect();
112
+
113
+ // We cannot apply this fix if nothing has been rendered into the `container`
114
+ if (rect.width === 0) {
115
+ return;
116
+ }
117
+ container.style.left = "-".concat(rect.width - 0.0001, "px");
118
+ });
103
119
  }
104
120
  nativeSetDragImage === null || nativeSetDragImage === void 0 || nativeSetDragImage(container, previewOffset.x, previewOffset.y);
105
121
  function cleanup() {
@@ -76,6 +76,7 @@ export function setCustomNativeDragPreview({
76
76
  * On `Safari@17.1` if a drag preview element has some opacity,
77
77
  * Safari will include elements behind the drag preview element
78
78
  * in the drag preview.
79
+ * Bug: https://bugs.webkit.org/show_bug.cgi?id=266025
79
80
  *
80
81
  * **Fix**
81
82
  * We push the drag preview so it is _almost_ completely offscreen so that
@@ -93,8 +94,23 @@ export function setCustomNativeDragPreview({
93
94
  * → Wrecks the opacity of the drag preview element
94
95
  */
95
96
  if (isSafari()) {
96
- const rect = container.getBoundingClientRect();
97
- container.style.left = `-${rect.width - 0.0001}px`;
97
+ /**
98
+ * For some frameworks (eg `react@18+` with `ReactDOM.createRoot().render()`) the rendering
99
+ * inside the `container` does not occur until after a microtask.
100
+ *
101
+ * Notes:
102
+ * - This will run before the browser takes it's picture of the element
103
+ * - This will run before the animation frame that removes `container`.
104
+ **/
105
+ queueMicrotask(() => {
106
+ const rect = container.getBoundingClientRect();
107
+
108
+ // We cannot apply this fix if nothing has been rendered into the `container`
109
+ if (rect.width === 0) {
110
+ return;
111
+ }
112
+ container.style.left = `-${rect.width - 0.0001}px`;
113
+ });
98
114
  }
99
115
  nativeSetDragImage === null || nativeSetDragImage === void 0 ? void 0 : nativeSetDragImage(container, previewOffset.x, previewOffset.y);
100
116
  function cleanup() {
@@ -76,6 +76,7 @@ export function setCustomNativeDragPreview(_ref) {
76
76
  * On `Safari@17.1` if a drag preview element has some opacity,
77
77
  * Safari will include elements behind the drag preview element
78
78
  * in the drag preview.
79
+ * Bug: https://bugs.webkit.org/show_bug.cgi?id=266025
79
80
  *
80
81
  * **Fix**
81
82
  * We push the drag preview so it is _almost_ completely offscreen so that
@@ -93,8 +94,23 @@ export function setCustomNativeDragPreview(_ref) {
93
94
  * → Wrecks the opacity of the drag preview element
94
95
  */
95
96
  if (isSafari()) {
96
- var rect = container.getBoundingClientRect();
97
- container.style.left = "-".concat(rect.width - 0.0001, "px");
97
+ /**
98
+ * For some frameworks (eg `react@18+` with `ReactDOM.createRoot().render()`) the rendering
99
+ * inside the `container` does not occur until after a microtask.
100
+ *
101
+ * Notes:
102
+ * - This will run before the browser takes it's picture of the element
103
+ * - This will run before the animation frame that removes `container`.
104
+ **/
105
+ queueMicrotask(function () {
106
+ var rect = container.getBoundingClientRect();
107
+
108
+ // We cannot apply this fix if nothing has been rendered into the `container`
109
+ if (rect.width === 0) {
110
+ return;
111
+ }
112
+ container.style.left = "-".concat(rect.width - 0.0001, "px");
113
+ });
98
114
  }
99
115
  nativeSetDragImage === null || nativeSetDragImage === void 0 || nativeSetDragImage(container, previewOffset.x, previewOffset.y);
100
116
  function cleanup() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/pragmatic-drag-and-drop",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "The core package for Pragmatic drag and drop - enabling fast drag and drop for any experience on any tech stack",
5
5
  "repository": "https://github.com/atlassian/pragmatic-drag-and-drop",
6
6
  "author": "Atlassian Pty Ltd",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@babel/runtime": "^7.0.0",
65
- "bind-event-listener": "^2.1.1",
65
+ "bind-event-listener": "^3.0.0",
66
66
  "raf-schd": "^4.0.3"
67
67
  },
68
68
  "devDependencies": {