SIGN IN SIGN UP

scrollable: Add explicit scroll identity for Scrollable (#2791)

## Description

Add `Scrollable::scroll_id` to allow callers to provide a stable and
unique identity for a scrollable element.

`Scrollable` currently uses `caller_id()` as the key for its internally
managed `ScrollHandle`. This works for statically declared scrollables,
but multiple scrollables created from the same call site, such as inside
an iterator or virtual list, may resolve to the same keyed scroll state.

For example, multiple horizontal scrollables created from the same
iterator call site can share their scroll position, causing all rows to
move when scrolling one of them.

This change adds an optional `scroll_id`:

```rust
.children((0..10).map(|ix| {
    div()
        .overflow_x_scrollbar()
        .scroll_id(format!("row-{ix}"))
        .child(...)
}))
```

When `scroll_id` is not specified, the existing `caller_id()` behavior
remains unchanged.

A regression test is included to verify that dynamically created
scrollables with unique scroll IDs maintain independent scroll state.

## Screenshot

Not applicable. This change does not introduce any visual changes.

## How to Test

Run the regression test:

```sh
cargo test dynamic_scrollables_with_unique_scroll_ids_keep_independent_state
```

The test creates multiple horizontal scrollables from the same call site
with different `scroll_id` values, scrolls the first one, and verifies
that the second scrollable remains unchanged.

## Checklist

- [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and
followed the guidelines.
- [x] Reviewed the changes in this PR and confirmed AI generated code
(If any) is accurate.
- [ ] Passed `cargo run` for story tests related to the changes.
- [ ] Tested macOS, Windows and Linux platforms performance (if the
change is platform-specific)

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
L
Lay committed
f599aebbcd884bf8372a647c8875aaa6f9be7c78
Parent: 9e6d500
Committed by GitHub <noreply@github.com> on 8/23/2026, 2:50:01 PM