Skip to content

Codemod remounts same-tag conditional inputs and loses user edits #2502

Closed

Description

@domgan-oai

Reproduction

This reproduces with @octanejs/codemod built from main at 0d651902818c6011e1d86d3b52bce6739ec11b52, the published Octane 0.16.7 compiler and runtime, React 19.2.7, and Chromium 149.

export function View({ active }: { active: boolean }) {
  return (
    <section>
      {active
        ? <input defaultValue="ready" />
        : <input defaultValue="later" />}
    </section>
  );
}
  1. Run the codemod with Strong mode, compiler verification and project types.
  2. Render the resulting component on the server and hydrate it with active: true.
  3. Focus the input, type typed text, select characters 2 through 5, and update active to false.

Expected

Both branches have the same intrinsic type at the same child position and neither has a key. React retains the hydrated input node, the user's text, focus and selection.

Actual

The codemod reports a clean Strong result and emits two separate template arms.

<section>
  @if (active) { <input defaultValue="ready" /> }
  @else { <input defaultValue="later" /> }
</section>

The initial Octane hydration adopts the server node. Switching arms replaces that node, resets the live value to later, and loses focus and selection. Both renderers report zero hydration recoveries.

A control using one native input template with defaultValue={active ? "ready" : "later"} retains the node, text, focus and selection. A codemod fix should preserve the shared element where its key, props and evaluation order allow it. Distinct types or keys still require separate identities.

Activity

  1. added
    agent-authored
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-authored

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions