Skip to content

Focus is lost after reordering items #15634

Closed
@abdel-17

Description

@abdel-17

Describe the bug

I have a recursive tree data structure, which is flattened to a list. Sometimes, when the items in the tree are reordered, the focused item loses focus. I suspect the DOM element is recreated, causing focus to be lost.

Reproduction

https://svelte.dev/playground/2556d9ee465d4ebfa431b03430ee6b45?version=5.25.3

  • Click on item 1.

  • 1 and 2 should swap order, but focus will be lost.

  • Click on 2.

  • It should swap without losing focus.

Logs

System Info

System:
    OS: macOS 15.3.2
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 21.63 MB / 16.00 GB
    Shell: 3.7.1 - /usr/local/bin/fish
  Binaries:
    Node: 23.7.0 - /usr/local/bin/node
    npm: 10.9.2 - /usr/local/bin/npm
    pnpm: 10.4.1 - /usr/local/bin/pnpm
    bun: 1.2.2 - /usr/local/bin/bun
  Browsers:
    Brave Browser: 134.1.76.74
    Safari: 18.3.1

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions