Skip to content

Fix InAppNotification not working show/hide/show sequence #3452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

vgromfeld
Copy link
Contributor

Fixes #3451

When using InAppNotification and running the Show()/Dismiss()/Show() sequence "too fast", we never see the last notification.

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

When running the following code in the InAppNotification sample page, we are not seeing the last notification:

 SampleController.Current.RegisterNewCommand("Show hide show", (sender, args) =>
 {
      _exampleInAppNotification?.Show("Notification 1", 0);
      _exampleInAppNotification?.Dismiss();
      _exampleInAppNotification?.Show("Notification 2", 0);
});

What is the new behavior?

The InAppNotification content visibility is driven by two VisualStates and the control visibility is controlled using its Visibility property.

When going "too fast", we have the following sequence:

  • show notification 1 is called
    -- control visibility set to visible
    -- request visual state change to "visible"
  • dismiss is called
    -- request visual state change to "hidden"
  • show notification 2 is called
    -- request visual state change to "visible"
    -- visual state changed to "visible"
    -- visual state changed to "hidden"
    -- control visibility set to collapsed (See OnNotificationCollapsed())
    -- visual state changed to "visible"

The visual states changed events are raised even if we've never really gone into the state and our event handler for the "hidden" state is forcing the control to be collapsed.
Forcing the control to be displayed when entering the visible state is ensuring that the control visibility remains synchronized with its content.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

@ghost
Copy link

ghost commented Aug 26, 2020

Thanks vgromfeld for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from michael-hawker, azchohfi and Kyaa-dost August 26, 2020 09:50
@ghost ghost added the bug 🐛 An unexpected issue that highlights incorrect behavior label Aug 26, 2020
@Kyaa-dost Kyaa-dost added this to the 7.0 milestone Aug 26, 2020
@Kyaa-dost
Copy link
Contributor

Kyaa-dost commented Aug 26, 2020

"D:\a\1\s\Windows Community Toolkit.sln" (Build target) (1) ->
"D:\a\1\s\Microsoft.Toolkit.Uwp.UI.Controls\Microsoft.Toolkit.Uwp.UI.Controls.csproj" (default target) (9:2) ->
(CoreCompile target) ->
InAppNotification\InAppNotification.cs(72,80): error SA1028: Code should not contain trailing whitespace [D:\a\1\s\Microsoft.Toolkit.Uwp.UI.Controls\Microsoft.Toolkit.Uwp.UI.Controls.csproj]

@vgromfeld Seeing this error regarding build failure

@Sergio0694
Copy link
Member

Looks great, good catch @vgromfeld! 🚀

@Sergio0694 Sergio0694 merged commit 3105e39 into CommunityToolkit:master Aug 31, 2020
@vgromfeld vgromfeld deleted the u/inAppNotificationShowHideShow branch September 1, 2020 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior needs author feedback 📝
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling show/dismiss/show on InAppNotification is not working
4 participants