Skip to content

DYN-10639: Fix toast notification position and premature dismissal#17180

Closed
RobertGlobant20 wants to merge 2 commits into
masterfrom
DYN-10639-toast-notification-position
Closed

DYN-10639: Fix toast notification position and premature dismissal#17180
RobertGlobant20 wants to merge 2 commits into
masterfrom
DYN-10639-toast-notification-position

Conversation

@RobertGlobant20

Copy link
Copy Markdown
Contributor

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 outgoing WorkspaceView (and its viewControlPanel) is torn out of the visual tree as the workspace swaps. The popup's PlacementTarget disconnects (This Visual is not connected to a PresentationSource) and WPF re-places the orphaned popup at the window origin.

Root cause — premature dismissal: OnCurrentWorkspaceChanged in the Python Migration view extension closed the toast unconditionally on every workspace change, dismissing unrelated toasts ~1s after they appeared.

Fix:

  • Anchor the popup to background_grid — the canvas background declared directly in DynamoView, which persists across workspace swaps (only the WorkspaceView content inside it changes). Its top-right corner coincides with the old viewControlPanel anchor, so the position is unchanged.
  • Use PlacementMode.Custom with a placement callback that pins the popup just inside the canvas top-right corner, independent of popup width.
  • Honor stayOpen so persistent toasts are not auto-closed after the timeout.
  • In 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)

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>
Copilot AI review requested due to automatic review settings June 19, 2026 16:26

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-10639

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.CreateRealTimeInfoWindow to anchor the popup to background_grid, use PlacementMode.Custom with a top-right placement callback, and only start the auto-close timer when stayOpen == false.
  • Update PythonMigrationViewExtension.OnCurrentWorkspaceChanged to 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.

Comment on lines +99 to 104
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) };
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +88 to +92
// Only start auto-close timer if the notification should not stay open
if (!stayOpen)
{
StartAutoCloseTimer(AutoCloseSeconds);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@RobertGlobant20

Copy link
Copy Markdown
Contributor Author

GIF showing the expected behavior.
PopupLocationFixed

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>
@RobertGlobant20

Copy link
Copy Markdown
Contributor Author

closing it in favor of #17183

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants