fix(ui): TranslateFromScreen resolves the surface offset for any surface root - #71
Merged
Merged
Conversation
…ace root (popup content GetPosition) UIElement.TranslateFromScreen only subtracted the surface offset when the visual root was a Window or the Popup element itself. A popup's hosted child is its own surface root (the Popup element stays in the owner's tree), so inside a popup placed away from the screen origin MouseEventArgs.GetPosition came back offset by the popup's (Left, Top) — hover and clicks in a drawn control inside a BarPopupButton dropdown landed rows and columns away from the pointer. Resolve the surface through WindowManager.SurfaceForElement, exactly as TranslateToScreen already does, so the two are inverses for every surface kind. Regression test: a popup placed below an offset target — element→screen→element round-trips and the dispatched press reports element-local cells. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013qbF5ru6uh5w7fqhP3yoPE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UIElement.TranslateFromScreensubtracted the surface offset only when the visual root was aWindowor thePopupelement. A popup's hosted child is its own surface root (thePopupstays in the owner's tree), so theroot is Popuparm never fired for popup content.MouseEventArgs.GetPosition(element)therefore came back offset by the popup's(Left, Top). Found via CursorialEdit's drag-to-size table picker (a drawnControlin aBarPopupButtondropdown): hover and clicks landed rows/columns away from the pointer whenever the dropdown opened below the ribbon rather than at the origin.WindowManager.SurfaceForElement(root), exactly asTranslateToScreendoes, so the two are inverses for every surface kind.Test plan
WindowPopupTests.PlacedPopup_TranslateFromScreen_AndGetPosition_AreElementLocal: a popup placed below an offset target — element→screen→element round-trips, and a dispatched press reports element-local cells.Cursorial.UI.Testsfull run: 3962 passed.🤖 Generated with Claude Code
https://claude.ai/code/session_013qbF5ru6uh5w7fqhP3yoPE