@dcl/react-ecs 7.22.4 → 7.22.5-24779418349.commit-111fd7e

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.
@@ -156,15 +156,11 @@ export function createReconciler(engine, pointerEvents) {
156
156
  const rightOfChild = parent._child.find((c) => c.rightOf === child.entity);
157
157
  if (rightOfChild) {
158
158
  rightOfChild.rightOf = child.rightOf;
159
+ // Re-order parent._child array
160
+ parent._child = parent._child.filter((c) => c.entity !== child.entity);
161
+ parent._child.push(child);
159
162
  updateTree(rightOfChild, { rightOf: rightOfChild.rightOf });
160
163
  }
161
- // Always remove from old position and push to end for reorders.
162
- // Previously, filter/push was inside the if(rightOfChild) block, so when
163
- // rightOfChild was not found (child was last), the child stayed at its old
164
- // position. This caused _child[length-2] to potentially be the child itself,
165
- // producing a self-referencing rightOf.
166
- parent._child = parent._child.filter((c) => c.entity !== child.entity);
167
- parent._child.push(child);
168
164
  // Its a re-order. We are the last element, so we need to fetch the element before us.
169
165
  child.rightOf = parent._child[parent._child.length - 2]?.entity;
170
166
  }
@@ -178,14 +174,13 @@ export function createReconciler(engine, pointerEvents) {
178
174
  }
179
175
  function removeChild(parentInstance, child) {
180
176
  const childIndex = parentInstance._child.findIndex((c) => c.entity === child.entity);
181
- if (childIndex !== -1) {
182
- const childToModify = parentInstance._child[childIndex + 1];
183
- if (childToModify) {
184
- childToModify.rightOf = child.rightOf;
185
- updateTree(childToModify, { rightOf: child.rightOf });
186
- }
187
- parentInstance._child.splice(childIndex, 1);
177
+ const childToModify = parentInstance._child[childIndex + 1];
178
+ if (childToModify) {
179
+ childToModify.rightOf = child.rightOf;
180
+ updateTree(childToModify, { rightOf: child.rightOf });
188
181
  }
182
+ // Mutate 💀
183
+ parentInstance._child.splice(childIndex, 1);
189
184
  removeChildEntity(child);
190
185
  }
191
186
  function updateOnChange(entity, componentId, state) {
@@ -263,23 +258,6 @@ export function createReconciler(engine, pointerEvents) {
263
258
  }
264
259
  },
265
260
  insertBefore(parentInstance, child, beforeChild) {
266
- // Handle reorder: if child already exists in this parent, remove it from its old position
267
- // and fix up the old neighbor's rightOf before inserting at the new position.
268
- const existingIndex = parentInstance._child.findIndex((c) => c.entity === child.entity);
269
- if (existingIndex !== -1) {
270
- // If beforeChild.rightOf already points to child, child is already in the correct
271
- // position in the rightOf chain. Setting child.rightOf = beforeChild.rightOf would
272
- // produce a self-cycle (child.rightOf = child.entity).
273
- if (beforeChild.rightOf === child.entity) {
274
- return;
275
- }
276
- const oldNextSibling = parentInstance._child[existingIndex + 1];
277
- if (oldNextSibling) {
278
- oldNextSibling.rightOf = child.rightOf;
279
- updateTree(oldNextSibling, { rightOf: oldNextSibling.rightOf });
280
- }
281
- parentInstance._child.splice(existingIndex, 1);
282
- }
283
261
  const beforeChildIndex = parentInstance._child.findIndex((c) => c.entity === beforeChild.entity);
284
262
  parentInstance._child = [
285
263
  ...parentInstance._child.slice(0, beforeChildIndex),
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dcl/react-ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.22.4",
4
+ "version": "7.22.5-24779418349.commit-111fd7e",
5
5
  "author": "DCL",
6
6
  "bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
7
7
  "dependencies": {
8
- "@dcl/ecs": "7.22.4",
8
+ "@dcl/ecs": "7.22.5-24779418349.commit-111fd7e",
9
9
  "react": "^18.2.0",
10
10
  "react-reconciler": "^0.29.0"
11
11
  },
@@ -40,5 +40,5 @@
40
40
  "tsconfig": "./tsconfig.json"
41
41
  },
42
42
  "types": "./dist/index.d.ts",
43
- "commit": "1309a552442670f22b64ad4cea1d88136188ad2f"
43
+ "commit": "111fd7e0b0b0fff32756dcb79c342b97a2565a45"
44
44
  }