DYN-10639: Fix toast notification position and premature dismissal#17180
DYN-10639: Fix toast notification position and premature dismissal#17180RobertGlobant20 wants to merge 2 commits into
Conversation
The toast popup (CreateRealTimeInfoWindow) was anchored to the per-workspace viewControlPanel. When a toast was raised during a workspace open (e.g. the legacy element-binding notification), that view was torn out of the visual tree as the workspace swapped, the PlacementTarget disconnected, and WPF re-placed the popup at the window origin instead of the top-right of the canvas. Anchor the popup to background_grid, the canvas background declared directly in DynamoView, which persists across workspace swaps. Use PlacementMode.Custom with a top-right placement callback so the popup is pinned just inside the canvas top-right corner regardless of its width, reproducing the original position. Also stop OnCurrentWorkspaceChanged from dismissing the toast on every workspace change; only close it when the previous workspace had shown the Python migration notification, so unrelated toasts are no longer closed ~1s after appearing. Honor stayOpen so persistent toasts are not auto-closed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-10639
There was a problem hiding this comment.
Pull request overview
This PR fixes two related toast-notification issues in the Dynamo WPF UI: (1) incorrect toast positioning during workspace swaps (caused by anchoring to a workspace-scoped visual that gets removed), and (2) premature toast dismissal triggered by the Python Migration view extension during workspace changes.
Changes:
- Update
ToastManager.CreateRealTimeInfoWindowto anchor the popup tobackground_grid, usePlacementMode.Customwith a top-right placement callback, and only start the auto-close timer whenstayOpen == false. - Update
PythonMigrationViewExtension.OnCurrentWorkspaceChangedto only close the toast on workspace change when the previous workspace actually showed the Python migration notification.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/PythonMigrationViewExtension/PythonMigrationViewExtension.cs | Avoids closing unrelated toasts on every workspace change by gating the close behavior on the prior workspace’s Python-migration flag. |
| src/DynamoCoreWpf/UI/ToastManager.cs | Makes toast positioning robust across workspace swaps by anchoring to background_grid, and aligns auto-close behavior with stayOpen. |
| private CustomPopupPlacement[] PlaceTopRight(Size popupSize, Size targetSize, Point offset) | ||
| { | ||
| var x = targetSize.Width - popupSize.Width - RightInset; | ||
| var y = TopInset; | ||
| return new[] { new CustomPopupPlacement(new Point(x, y), PopupPrimaryAxis.None) }; | ||
| } |
There was a problem hiding this comment.
Addressed in 92b1774: X is now clamped with Math.Max(RightInset, targetSize.Width - popupSize.Width - RightInset), so a canvas narrower than the popup can no longer push the toast off the left edge.
| // Only start auto-close timer if the notification should not stay open | ||
| if (!stayOpen) | ||
| { | ||
| StartAutoCloseTimer(AutoCloseSeconds); | ||
| } |
There was a problem hiding this comment.
Good catch — fixed in 92b1774. TestToastAutoCloses now asserts a sticky (stayOpen: true) toast stays visible past AutoCloseSeconds, and I added WhenToastIsNotStickyThenItAutoCloses to keep coverage on the auto-close path.
Update TestToastAutoCloses to the new stayOpen semantics: a sticky toast (stayOpen: true) now stays visible past AutoCloseSeconds, and a new test covers the non-sticky auto-close path. Clamp the custom placement X so a canvas narrower than the popup cannot push the toast off the left edge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
closing it in favor of #17183 |
|




Purpose
Fixes DYN-10639.
The toast notification shown by
ToastManager.CreateRealTimeInfoWindow(e.g. the legacy element-binding warning shown on opening an older workspace) appeared in the middle of the canvas / over the title bar instead of the top-right, and could disappear almost immediately after appearing.Root cause — position: the popup was anchored to the per-workspace
viewControlPanel. When a toast is raised mid workspace-open, the outgoingWorkspaceView(and itsviewControlPanel) is torn out of the visual tree as the workspace swaps. The popup'sPlacementTargetdisconnects (This Visual is not connected to a PresentationSource) and WPF re-places the orphaned popup at the window origin.Root cause — premature dismissal:
OnCurrentWorkspaceChangedin the Python Migration view extension closed the toast unconditionally on every workspace change, dismissing unrelated toasts ~1s after they appeared.Fix:
background_grid— the canvas background declared directly inDynamoView, which persists across workspace swaps (only theWorkspaceViewcontent inside it changes). Its top-right corner coincides with the oldviewControlPanelanchor, so the position is unchanged.PlacementMode.Customwith a placement callback that pins the popup just inside the canvas top-right corner, independent of popup width.stayOpenso persistent toasts are not auto-closed after the timeout.PythonMigrationViewExtension, only close the toast on workspace change when the previous workspace had actually shown the Python migration notification.Declarations
Check these if you believe they are true
Release Notes
Fixed the in-canvas toast notification (such as the legacy element-binding warning) so it consistently appears in the top-right of the canvas and is no longer mispositioned or dismissed immediately when opening a workspace.
Reviewers
(FILL ME IN)
FYIs
(FILL ME IN, Optional)