Vega-carousel 1.0.1: pinned rows jump on focus change and can't return to the first item after scrolling (RN 0.83, OS 2.0)

# :backhand_index_pointing_right: Bug Description

—

## 1. Summary

In a horizontal `Carousel` from `@amazon-devices/vega-carousel` 1.0.1 with `selectionStrategy=“pinned”`, the row scrolls by roughly one card whenever focus leaves it or comes back to it, but only after the selection has moved to the end of the row and back to the first item. With the first item selected, the focused row shows that item at the row’s start. As soon as focus moves to the row below, the unfocused row scrolls about one card to the left, so the first item is pushed off-screen and only a sliver of it is visible. Moving focus back up scrolls the row right again to show the first item, and moving down again shifts it left again. The same row with `selectionStrategy=“natural”` does not move at all.

A second, more serious symptom: after scrolling a pinned row a few items to the right and back, the carousel no longer lets the selection return to the first item. Left from the second item does nothing, so the first item, and anything reached by Left from it (our side menu via `nextFocusLeft`), becomes unreachable until the screen is reloaded. With `selectionStrategy=“natural”` the same steps work.

**App Name**: STARZ

**App Link on Amazon Appstore**: [fill in]

**Bug Severity**

Select one that applies [x]

* [x] Impacts operation of app

* [x] Blocks current development

* [ ] Improvement suggestion

* [ ] Issue with documentation

* [ ] Other

Every swimlane on our Home screen is a pinned carousel stacked in a vertical list, so normal Up/Down navigation makes rows jump sideways. This blocks our migration to RN 0.83 / vega-carousel 1.0.1. The same screens on RN 0.72 with vega-carousel 0.2.x do not do this.

## 2. Steps to Reproduce

1. Render two or more horizontal pinned carousels stacked vertically (configuration in section 7), each with more items than fit on screen.

2. Focus the top row and press Right until the last item is selected.

3. Press Left until the first item is selected again. The first item is fully visible at the start of the row (screenshot 1).

4. Press Down to move focus to the row below. The top row scrolls about one card to the left: the first item is now mostly off-screen and the second item sits where the first one was (screenshot 2).

5. Press Up. The top row scrolls right again to show the first item, which has focus.

6. Press Down again. The top row shifts left again. This repeats on every Up/Down.

Second symptom (can’t return to the first item):

1. Focus the first item of a pinned row (its `nextFocusLeft` points at a side menu outside the carousel).

2. Press Right three times, then Left three times.

3. Focus is on the second item, which now sits at the row’s start; the first item is scrolled off to the left.

4. Press Left again, any number of times. Nothing happens: the selection never returns to the first item, and the side menu is never reached.

## 3. Observed Behavior

```

After step 3, the horizontal scroll position of a pinned row depends on whether the row has focus:

Row state First item (index 0) Second item (index 1)

Focused, index 0 selected fully visible at row start next to it

Unfocused, index 0 selected only a ~40 px sliver visible at the row start (about one card further)

The selected index does not change: on re-entry focus lands on index 0 again, and the row scrolls back.

Second symptom, focus events logged from each item’s onFocus during the steps above

(Down into the row, Right x3, Left x4):

pinned: index 0 → 1 → 2 → 2 → 1 → stuck on 1 (the third Right also did not advance;

      further Left presses do nothing)

natural: index 0 → 1 → 2 → 3 → 2 → 1 → 0 → side menu (nextFocusLeft)

```

## 4. Expected Behavior

```

Left should always move the selection back to the previous item, including to index 0 after the row has scrolled.

A row’s scroll position should not change when focus moves to another row and back. The unfocused row

should stay exactly where it was while focused, as it does with selectionStrategy=“natural” (screenshot 3)

and as it did with vega-carousel 0.2.x.

```

### 4.a Possible Root Cause & Temporary Workaround

```

Root cause: unknown (the scrolling happens in com.amazon.keplerscript.carousel.so, which JS cannot inspect).

It looks as if the carousel keeps the scroll position from the last time an item was pinned (index 1,

while moving left from the end) and re-applies it when the row loses focus, instead of the position it is

actually showing for index 0 at the start of the row.

What we tried:

- selectionStrategy=“natural”: no shift, but the focused item floats instead of staying pinned, which

changes our UX.

- Changing pinnedSelectedItemOffset (several percentages, and ‘start’): either the shift remains, or the

first item is clipped at the row start, or the end of the row lays out incorrectly. We found no offset

where the start of the row, the end of the row and focus changes all behave.

- Calling scrollTo(0, false) on the ref when the selection reaches index 0: does not prevent the shift.

We also noticed that the documented pinnedSelectedItemOffset does not match where the item lands. Our device

measurements show the pinned item’s centre (not its leading edge) is placed at the offset, and with a 0%

offset the selected card is clipped under our side menu. We compensate by computing the percentage from the

measured card width.

Workaround: none that keeps pinned behaviour.

```

## 5. Logs or crash report

No crash or error is logged; this is a layout issue. Attached:

* `1_row-focused_first-card-at-start.png`: after step 3, with focus on the first item of the top row (“Leaving Soon”).

* `2_row-unfocused_shifted-one-card.png`: after step 4, with focus on the row below. The top row has shifted about one card left.

* `3_natural-strategy_no-shift.png`: the same sequence with `selectionStrategy=“natural”`. No shift.

## 6. Environment

* **SDK Version:** Active SDK Version 0.24.9859

* **React Native Version:** `react-native` 0.83.0, `@amazon-devices/react-native-kepler` 4.0.1+rn0.83.0

* **vega-carousel Version:** `@amazon-devices/vega-carousel` 1.0.1

* **App State:** Foreground

* **Device:** Fire TV Stick (callie, armv7)

* **OS Information:** `BUILD_DESC=“OS 2.0 (TV Ship/529)”`, `BUILD_FINGERPRINT=“4.0.539433.0(3072cab629675a74)/529N:user/release-keys”`, `VERSION_NUMBER=“2602000052920”`, `RELEASE_ID=“26”`

## 7. Example Code Snippet / Screenshots / Screengrabs

```tsx

import { Carousel } from ‘@amazon-devices/vega-carousel’;

// One of several rows stacked in a vertical list; each row has ~10-20 items, cards are 400 x 225.

<Carousel

animationDuration={{ itemScrollDuration: 0.1 }}

containerStyle={{ marginRight: -140 }} // row overflows the right edge so the last card can reach it

dataAdapter={dataAdapter}

itemStyle={{ itemPadding: 30, pressedItemScaleFactor: 1.0, selectedItemScaleFactor: 1.0 }}

navigableScrollAreaMargin={5}

pinnedSelectedItemOffset={pinnedOffset} // (cardWidth / 2) / (rowWidth + overflow - 2 * margin), as a percentage

renderItem={renderItem}

renderedItemsCount={10}

selectionStrategy=“pinned”

uniqueId={uniqueId}

/>

```

We have not yet reproduced it in a minimal new app; we can provide one if that would help.

—

## :backhand_index_pointing_right: Playback Issues

—

```

N/A

```

—

## :backhand_index_pointing_right: Additional Context

—

```

Questions:

1. Is a pinned carousel expected to re-layout when focus leaves and re-enters it? If so, is there a prop

to keep the current scroll position on blur?

2. What is the exact geometry for pinnedSelectedItemOffset in 1.0.1 (leading edge vs centre, and which

width the percentage applies to), so we can place the pinned item at the row’s start without clipping?

```

Hi @Phi_Huynh,

Thank you for the detailed bug report on pinned vega-carousel 1.0.1 rows shifting on focus changes and not returning to the first item after scrolling. Our team is investigating this issue and will provide an update as soon as we have more information.

To help with the investigation, could you please share the minimal app you mentioned that reproduces the issue? Please also let us know whether you see it in a Release build as well as a Debug build.

Thanks for helping us improve the Vega platform.

Warm regards,
Aishwarya

Hi Aishwarya,

  1. A minimal app is attached (vega-carousel-pinned-repro.zip): a new RN 0.83 Vega app with two Carousel rows using selectionStrategy="pinned" with our swimlane settings (Row A 400 px items, Row B 294 px items) and a Menu button as the first items’ nextFocusLeft. The README has build steps and repro steps.
  2. Release: yes. The “can’t return to the first item” issue reproduces in a Release build of the attached app (Vega Virtual Device, SDK 0.24.12112). Row B: Right ×3 then Left ×5 gives item 1 → 2 → 3 → 2 → 1, then stuck. Row A goes back to item 0 and the Menu. In our app we’ve seen both issues in Debug on a Fire TV Stick (OS 2.0, TV Ship/529).

Only the row with the narrower items gets stuck; the 400 px row only shows the jump described in the report.


App.tsx (5.3 KB)
manifest.toml (567 Bytes)
package.json (1.9 KB)
README.md (2.9 KB)

On RN 0.83 the swimlanes use vega-carousel 1.0.1, where scrolling happens in native code. Develop uses the older 0.2 carousel and doesn’t have these bugs.
Pinned (develop’s behaviour, the focused card stays at the left)

  • Placement: 1.0.1 puts the pinned card in the wrong place. With develop’s 'start' value, the focused card is cut off under the side nav, and the end of the row scrolls too far, leaving empty space.
  • Our workaround: StarzCarousel calculates the offset and makes the row hang off the right edge. That fixes the start and end of the row, but leaves two bugs:
    • Row jump (all rows): after you visit the end of a row and come back to the first card, the row moves about one card every time focus goes to another row and back.
    • Stuck on card 2 (portrait rows only, STARZ Originals on Home and Search): after scrolling right and back, Left stops at the second card. The first card and the side nav can’t be reached.
  • Tuning: no offset we tried fixed these without clipping the first card or breaking the end of the row.

Natural (the focused card moves along the row)

  • No row jump, and never stuck. Left always gets back to card 0 and then the side nav, verified on the stick.
  • The look differs from develop: the focused card isn’t held at the left, and the last card sits flush to the right edge.

Hi @Phi_Huynh,

Thank you for sharing the minimal repro app. It helped our team look into this quickly.

Please upgrade to @amazon-devices/vega-carousel 1.0.5, which is now the latest version on npm: https://www.npmjs.com/package/@amazon-devices/vega-carousel/v/1.0.5

Our team verified with your minimal app that this version fixes the issue where Left can’t return to the first item after scrolling a pinned row.

When upgrading, please note:

  1. Retune pinnedSelectedItemOffset: in 1.0.5, the selected item’s leading edge sits at the offset, so ‘0%’ places the first card at the start of the row. You may no longer need the offset calculation and row overflow you added as a workaround.
  2. Add recyclerlistview to your app’s dependencies.

Once you’ve upgraded, could you please retest both issues (Left not returning to the first item, and pinned rows shifting when focus moves to another row and back) and let us know the results?

Thanks for helping us improve the Vega platform.

Warm regards,
Aishwarya