Empower growth and innovation with the latest Front-end Dev insights

In 2026, when deleting a middle row in a React list makes unsubmitted text in the input fields below shift down, is the key wrong or is the controlled component not properly controlled?

Nov 23, 2026 Read: 31

Bottom line first: When deleting a middle row causes text in the input fields below to shift, it is usually not because a controlled component is missing value; it is because the list key uses the array index. During reconciliation, React uses the key to decide whether “this row is still the same row as in the previous render.” The index moves forward as a whole after deletion, so old component instances and DOM are mismatched to the next row, and input values, focus, and drafts move with them. In 2026, when working on a back-office editable list, check whether the key identity is stable first, then check the controlled pattern; that troubleshooting order saves time.

The input is not broken; React is treating this row as the adjacent row

When React updates a list, it does not rebuild the whole segment; it compares the keys of the old and new subtrees: if the key is the same, it reuses the original component instance and DOM node and only patches in the changed props. index is a position number. After row 2 is deleted, the original row 3 becomes position 2, which exactly matches the previous key=2 instance, so React thinks “it is still that row, only the content changed” and puts the new row data into the old instance.

Reuse itself is not wrong; the mistake is that the reused object is identified incorrectly. As long as a row contains state not fully managed by React—unsubmitted input, cursor position, expanded/collapsed state, inline validation messages—it stays in place with the old instance while the data has already switched to the next row. That is the whole process of text shifting, and it is where the issue is most easily misdiagnosed as a controlled component missing value.

  • What shifts together: unsubmitted input values, focus, expanded state, inline error messages, and animation progress.
  • What does not shift: plain text cells, because the rendered output is determined by the new data and no abnormality is visible to the naked eye.
  • What is easiest to miss in testing: it only reproduces in half-filled, editing, or draft states; a purely browsing main flow cannot trigger it.

First decide what identifies this row: four questions about row identity

Choosing a key is essentially identity modeling, not a code style question. Run through the four questions below, and what key most lists should use will usually become obvious; it also helps avoid over-fixing such as switching the whole site to id.

  1. Will this row be deleted, inserted, or reordered? For append-only log-type lists that never change order, the side effects of index are limited; for editable lists that can add, delete, and sort, using index will basically cause problems.
  2. Does the data have a stable unique identifier? Prefer backend-generated fields such as id, code, or sku plus warehouse code; if not, have the data-fetching layer add a local uid.
  3. Can the same identifier appear twice? It may repeat with merged rows, multi-SKU rows, or cross-page concatenation, and key collisions are harder to troubleshoot than index.
  4. How should temporary rows be identified? Rows added locally in the front end and not yet persisted to the database need a temporary id first, then switch to the server id after successful submission; do not fall back to index in between.

The order of the four questions matters: first ask whether it will change, then ask whether there is an identifier, and only then handle temporary state. Jumping to the last question first often creates a secondary issue during submit backfill: the newly added row flickers in place. Passing means deleting a middle item does not shift state, batch deletion does not shift state, and paginated appends do not flicker.

Trade-off between index and business ID: do not apply a blanket rule; see whether the list changes

After being burned once by shifting state, many teams switch all keys site-wide to id; that is over-fixing. What really determines cost is whether the list can add, delete, and reorder, and whether rows have local state. When neither is true, the return on refactoring is close to zero.

  • index key: There is basically no refactoring location, and typical time is close to zero; it suits read-only, append-only lists with no local row state. When the list can add, delete, and sort and rows contain inputs, the risk of state misalignment rises as the list gets longer.
  • Business ID key: Refactoring usually lands in two places, the data-fetching layer and the list component; for a single list, the typical range is about 0.5–2 hours. For batch troubleshooting across multiple pages, following 2026 project delivery habits, the typical range is about 1–3 person-days.
  • Local uid key: A compromise when the backend truly cannot provide a unique field; it adds a mapping layer. The typical cost is one extra step for new-row backfill, and the refactoring range is usually slightly higher than for a business ID.

In comparison, the basis for choosing is not “which pattern is more standard,” but “will this row change position right in front of the user?” The criterion can be fixed: as long as the list supports deleting any row and rows contain inputs, do not use index; if the list is read-only, append-only, and has no local row state, the actual risk of continuing to use index is usually very low.

On the delivery floor: saving half an hour led to half a day of retesting

In back-office editable-list projects, a common constraint is a two-week schedule, APIs provided by the client’s backend, and a list API that returns only name and time with no unique field; to keep up with integration testing, the front end uses index first. The first round of functional testing all passes because the test paths are all fill-then-submit. At the acceptance meeting, someone half-fills a row and then deletes a row above it, and the draft shifts to the next row before the issue is exposed.

Following 2026 delivery habits, the usual fix is to go back to the data-fetching layer and add a stable id layer without touching the backend: on first receiving the data, generate a uid from name, time, and sequence number and cache it; deletion, appending, and pagination all reuse the same mapping. The cost is an extra mapping layer and one round of field-confirmation communication with the backend. The typical rework range is half a day to a day, mainly spent on retesting and regression rather than on changing the code itself.

Pre-release acceptance: go through six actions one by one

Key problems are almost invisible on normal click paths, so acceptance testing must deliberately create states rather than just walk through the main flow. The six actions below can be completed in about ten minutes; if any one fails, identity modeling is not right yet.

  • Delete a middle row: delete while a row is half-filled, and see whether values in the input fields below move up with it.
  • Insert at the top: add a pinned record and see whether focus and expanded state from existing rows are stolen.
  • Batch delete: select multiple rows and delete them consecutively, and see whether a validation message from row B remains after row A is deleted.
  • Paginated append: when the second page of data is loaded, see whether the whole list flickers or scrolls back to the top.
  • Submit after local add: when a temporary row switches to a server id, see whether the whole row is rebuilt and whether the enter animation replays.
  • Switch sorting: after the sort changes, see whether unsubmitted content in a row follows the data or stays in place.

State the pass criteria clearly: after delete, insert, and sort operations, user-visible state inside a row must follow the data, not the position.

Applicable scenarios and boundaries: when there is no need to change the key

Lists worth prioritizing are those that can add, delete, and sort plus have local row state: back-office editable tables, form lists with drafts, drag-and-drop sortable configuration items, and multi-SKU product rows. If the key is wrong in these lists, it is more likely to surface during acceptance or after launch, and the later it is found, the more expensive it gets.

There are also cases that do not warrant over-engineering: purely read-only display lists, scenarios where data is replaced as a whole at once and rows have no local state, and scenarios with very few rows that are never added to or deleted from. In these cases, the actual risk of continuing to use index is usually very low, and refactoring the data-fetching layer specifically for them is not worthwhile. The boundary can be summed up in one sentence: only when both are true—the row can change position, and users can tell when it changes position—does the key need to be changed first.

Common questions

If the key uses index and the console reports no error, why is it still considered a problem?

It does not report an error because React only reuses instances by key and does not verify whether that key represents the same row. The symptom is misaligned row state, not an exception, so it can only be tested by deliberately creating delete, insert, and sort states.

If the backend has no unique field, is it a hack for the front end to create an id itself?

No. Adding a stable uid in the data-fetching layer is a common practice. The key is to ensure that the same record gets the same value across multiple renders, pagination, and submit backfill, rather than generating a temporary value every round.

If the input is changed to uncontrolled and the value is read only when needed, does that mean the key no longer matters?

No. Uncontrolled only stores the value in the DOM. When the instance is reused, that DOM still stays with the old row, and shifting still happens; it just moves from the React state layer to the DOM layer, where it is more hidden.

If the key concatenates the index, such as id plus index, can it achieve both uniqueness and stability?

No. If the index changes, the key changes, which means rebuilding the instance every round; drafts, focus, and expanded state in the row are reset across the board, and the cost is usually more obvious than simple state shifting.


If you happen to have a list that can delete and edit, spend ten minutes running the six actions above before deciding whether to change the key; read-only lists do not need to follow along. When rows contain drafts, focus, or expanded state and the list supports delete and sort, changing the key to a stable identifier is a step with clear returns; conversely, rewriting the data-fetching layer for a purely display list usually only increases long-term maintenance surface.

Have a similar project in mind?
Contact us for a one-to-one project reference proposal
Obtain Proposal
Interested in this topic?
10-year tech team — reference proposal within 24 hours
Obtain Proposal
Are you ready?
Then reach out to us!
+86-13370032918
Discover more services, feel free to contact us anytime.
Please fill in your requirements
What services would you like us to provide for you?
Your Budget
ct.
Our WeChat
Professional technical solutions
Phone
+86-13370032918 (Manager Jin)
The phone is busy or unavailable; feel free to add me on WeChat.
E-mail
349077570@qq.com
Submitted successfully
Thank you for your trust. We will contact you soon!
Recommended projects for you