Skip to content

applib/menu_layer: keep a mid-pan reload off the finger-owned offset - #1895

Draft
Mearman wants to merge 1 commit into
coredevices:mainfrom
Mearman:fix/menu-layer-reload-mid-pan
Draft

applib/menu_layer: keep a mid-pan reload off the finger-owned offset#1895
Mearman wants to merge 1 commit into
coredevices:mainfrom
Mearman:fix/menu-layer-reload-mid-pan

Conversation

@Mearman

@Mearman Mearman commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Draft — still validating on hardware.

The last one I could reliably reproduce while playing with touch: on a center-focused carousel (the launcher), a data refresh landing mid-drag made the list visibly jump — yank one way, snap straight back — and feel desynced from my finger for the rest of the gesture.

menu_layer_update_caches finishes by re-selecting the current row with MenuRowAlignNone, and prv_corrected_scroll_align promotes that to MenuRowAlignCenter on center-focused menus. A reload mid-pan (timer, inbox, timeline update) therefore snaps the offset to re-centre the selection under a finger that is still down — and the next pan update recomputes from the gesture's base offset, jumping the content straight back. The code's own invariant says menu_layer_set_selected_index cannot be used mid-pan for exactly this reason.

The fix keeps the promotion but not while a touch gesture owns the menu: the finger owns the offset until liftoff, when the carousel settles through prv_menu_touch_settle_to_center as before. Callers that genuinely want a re-centre pass MenuRowAlignCenter explicitly and are unaffected, and the button-path reconcile still promotes because no gesture is active when buttons are pressed.

Covered by test_menu_layer__dispatch_pan_reload_mid_gesture_keeps_offset; full unit suite green.

menu_layer_update_caches finishes by re-selecting the current row with
MenuRowAlignNone, and prv_corrected_scroll_align promotes that to
MenuRowAlignCenter on center-focused menus. A reload_data arriving
mid-pan (timer, inbox, timeline update) therefore snaps the scroll
offset to re-centre the selection under a finger that is still down --
and the next pan update computes from the gesture's base offset,
jumping the content straight back. The code's own invariant says
menu_layer_set_selected_index cannot be used mid-pan for exactly this
reason.

Keep the promotion, but not while a touch gesture owns the menu: the
finger owns the offset until liftoff, when the carousel settles through
prv_menu_touch_settle_to_center as before. Callers that genuinely want
a re-centre pass MenuRowAlignCenter explicitly and are unaffected, and
the button-path reconcile still promotes because no gesture is active
when buttons are pressed.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Joseph Mearman <joseph@mearman.co.uk>
@Mearman
Mearman force-pushed the fix/menu-layer-reload-mid-pan branch from 5741b32 to dda47a5 Compare August 19, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant