Skip to content

Clicking to focus child inside ScrollablePanelControl causes scroll jump #8

Description

@nickprotop

Description

When clicking on a visible interactive control inside a scrolled-down ScrollablePanelControl (SPC), the panel jumps — often to the top. This breaks click-to-focus UX in any dialog with scrollable content.

Root Cause

FocusManager.SetFocus(spc, FocusReason.Mouse) treats SPC as an IFocusScope and delegates focus to GetInitialFocus(), which returns the first focusable child — not the one actually clicked. This triggers ScrollChildIntoView on the wrong child, causing a scroll jump. The control's own ProcessMouseEvent then correctly focuses the clicked child, but the scroll damage is already done.

The chain:

  1. HandleClickFocusFocusManager.HandleClick walks up to SPC
  2. SetFocus(SPC, Mouse) sees IFocusScope → calls GetInitialFocus(false) → returns first child
  3. EnterOrFocus(firstChild) hardcodes FocusReason.Keyboard, losing the Mouse reason
  4. ScrollChildIntoView(firstChild) fires → scroll jumps to first child
  5. SPC's ProcessMouseEvent then correctly focuses the clicked child — but too late

Expected Behavior

Clicking a visible control inside a scrolled SPC should focus that control without any scroll position change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions