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:
HandleClickFocus → FocusManager.HandleClick walks up to SPC
SetFocus(SPC, Mouse) sees IFocusScope → calls GetInitialFocus(false) → returns first child
EnterOrFocus(firstChild) hardcodes FocusReason.Keyboard, losing the Mouse reason
ScrollChildIntoView(firstChild) fires → scroll jumps to first child
- 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.
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 anIFocusScopeand delegates focus toGetInitialFocus(), which returns the first focusable child — not the one actually clicked. This triggersScrollChildIntoViewon the wrong child, causing a scroll jump. The control's ownProcessMouseEventthen correctly focuses the clicked child, but the scroll damage is already done.The chain:
HandleClickFocus→FocusManager.HandleClickwalks up to SPCSetFocus(SPC, Mouse)sees IFocusScope → callsGetInitialFocus(false)→ returns first childEnterOrFocus(firstChild)hardcodesFocusReason.Keyboard, losing the Mouse reasonScrollChildIntoView(firstChild)fires → scroll jumps to first childProcessMouseEventthen correctly focuses the clicked child — but too lateExpected Behavior
Clicking a visible control inside a scrolled SPC should focus that control without any scroll position change.