Skip to content

2.0.0-beta.14 createProjection has issues when calling splice on a draft array of objects #2754

@DominicDolan

Description

@DominicDolan

Describe the bug

When using createProjection in Solid 2.0, mutating the draft proxy array by setting an element and subsequently modifying its properties inline causes issues if a preceding element is deleted via .splice(). The subsequent elements are shifted down in index, but their assigned properties are lost or not correctly tracked/re-emitted.

// 1. Assigning the base element to an index
draft[index] = { id: item.id };

// 2. Setting individual properties sequentially
draft[index].status = item.status; // <---   These assignments are dropped
draft[index].title = item.title;   // <---   for shifted elements after splice

// ... later in the block ...
draft.splice(i, 1); // Triggers the bug

Your Example Website or App

https://stackblitz.com/edit/vitejs-vite-otx8tbew?file=src%2FApp.tsx

Steps to Reproduce the Bug or Issue

  1. Go to stackblitz example
  2. Click delete on either T1 or T2

The title and status values disappear from T3 in the "Not working" example

Repro steps in code:

  1. Create a projection draft array with objects
  2. Update an item by first assigning the base object: draft[index] = { id: item.id }
  3. Mutate that newly assigned object's properties inline: draft[index].title = item.title
  4. Later in the same execution block, remove a previous item from the array using draft.splice(i, 1)
  5. Trigger a reactivity update (e.g., updating the deleted signal).

Expected behavior

The remaining items should shift down in the array while maintaining their complete internal state (id, title, and status).

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions