Skip to content

[MVUX] ListState<Uri>.AddAsync causes Selection/State.Empty.ForEach callback to fire with null before the actual selected value #2942

Closed

Description

@DevTKSS

Current behavior

When calling .AddAsync(uri,ct), where Uri has the value of https://platform.uno/studio/ at this time, on a ListState<Uri>.Async( ... .Selection(AnyUriState) the AnyUriState.Empty(this).ForEach( Operator callback handler should not get called with null AND THEN with the expected Value of https://platform.uno/studio/
seems a bit like the .Empty(this) might be resetting it? but should not be the case...

Expected behavior

The ForEach Operator Callback handler should only get called with the value that has been added + selected!

How to reproduce it (as minimally and precisely as possible)

Repro: UnoWebViewReproApp1.zip

  • Start the app, it will show you MainPage
  • If not preserved, go into MainModel and set Breakpoints on
    • HistorySelectionChanged Callback Handler 1. Line (logger)
    • CurrentUrlChanged in the AddAsync and TrySelectAsync Lines relativly on the bottom area of the method
  • now in the WebView2, which is showing the Uno Homepage, click on Platform in the Head Navigation (most likly you will need to use the Hamburger Icon before, since we are not able to Have the WebView2 Resized automatically on Window resizing) so you will get Navigated to this page
  • check out the Console, which should be containing this MainModel Log lines:
    info: UnoWebViewReproApp1.Presentation.MainModel[0]
          CurrentUrlChanged Adding https://platform.uno/platform/ to NavigationHistory
    info: UnoWebViewReproApp1.Presentation.MainModel[0]
          CurrentUrlChanged Selected https://platform.uno/platform/ in NavigationHistory
    warn: UnoWebViewReproApp1.Presentation.MainModel[0]
          HistorySelectionChanged Got parameter: https://platform.uno/platform/, this is type of: Uri
    info: UnoWebViewReproApp1.Presentation.MainModel[0]
          HistorySelectionChanged Selected Uri from CurrentUrl: https://platform.uno/platform/
    
    this output would be alright!
  • now click again on the Homepage on Studio to get navigated to this.
  • Inspecting the Console output now will show you the issued Behaviour in the third logged entry:
    info: UnoWebViewReproApp1.Presentation.MainModel[0]
          CurrentUrlChanged Adding https://platform.uno/studio/ to NavigationHistory
    info: UnoWebViewReproApp1.Presentation.MainModel[0]
          CurrentUrlChanged Selected https://platform.uno/studio/ in NavigationHistory
    warn: UnoWebViewReproApp1.Presentation.MainModel[0]
          HistorySelectionChanged Got parameter: (null), this is type of: (null)
    warn: UnoWebViewReproApp1.Presentation.MainModel[0]
          HistorySelectionChanged Got parameter: https://platform.uno/studio/, this is type of: Uri
    info: UnoWebViewReproApp1.Presentation.MainModel[0]
          HistorySelectionChanged Selected Uri from CurrentUrl: https://platform.uno/studio/
    
  • I added the mentioned Breakpoints and found out that we are getting the null value argument, even if its set to not nullable Uri type and on clicking continue, it gets a second call (we did only call Selection once if you inspect the code:
        public IListState<Uri> WebNavigationHistory => ListState<Uri>.Async(this,
                async ct =>
                {
                    var current = await CurrentUrl;
    
                    return current is not null
                        ? [current]
                        : [];
                })
                .Selection(SelectedNavigationHistoryItem);
        public IState<Uri> SelectedNavigationHistoryItem => State<Uri>.Empty(this)
                                                                      .ForEach(HistorySelectionChanged);

closely inspecting the logger lines producement order:

  • when we are calling AddAsync the value is not null then the valid url.
  • the HistorySelectionChanged gets called with null argument and loggs its initial line
  • Debugger steps to CurrentUrlChanged > TrySelectAsync
  • Debugger steps to HistorySelectionChanged >if statement with null value, so does not enter the statement and leaves the method
  • Now we seem to proceed reacting on TrySelectAsync and getting send to the HistorySelectionChanged with this call (again) and et voila, now we do have the value in the call and getting the appropriate reaction of logging with the url
  • UpdateAsync now gets called (and the debugger switches back and forth again) and our code proceedes as expected WITH the values instead of null.

Environment

For bug reports Check one or more of the following options with "x" (???)

VS 2026 Windows

Nuget Package (s):

Package Version(s):

Uno.Sdk first discovered as issue with MvuxListApp Repro using 6.3.28
still an issue with 6.4.13

Affected platform(s):

  • iOS
  • macOS (AppKit)
  • Mac Catalyst
  • Android
  • WebAssembly
  • Windows
  • Desktop
  • Skia (Linux Framebuffer)
  • Build tasks

Visual Studio:

  • 2019 (version: )
  • 2022 (version: )
  • 2026 (version: 18.0.0)
  • Visual Studio Code (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

mentioned this null value introduction in #2927 in which sample the connected TextBox to the Selected Item does NOT show any value and seems to stay on the null value instead of getting updated with the secondary call 🤔

Repro for this:
MvuxListApp.zip

hoping that anyone could have this fixed in the Reactive Packages of uno...

Activity

  1. added
    kind/bug
    triage/untriaged
    on Nov 12, 2025
  2. kazo0 commented on Nov 13, 2025

    @kazo0
    Contributor
  3. added theissue type on Nov 17, 2025
  4. removed
    kind/bug
    triage/untriaged
    on Nov 17, 2025
  5. DevTKSS commented on Nov 30, 2025

    @DevTKSS
    ContributorAuthor

    @kazo0 @dr1rrb FYI:
    Still issued with Uno.Sdk version 6.4.31

  6. DevTKSS commented on Dec 11, 2025

    @DevTKSS
    ContributorAuthor

    @dr1rrb @kazo0 seems like the fixing PR just needs to get merged, but Copilot didn't sign the Contribution Licensing 🤣 could you check up with him to get it throught? with the WebView2 fix applyed in the latest pre this would be the last rock to roll to finally get my Tutorial published about using WebView2 in Uno with Mvux 🚀

  7. kazo0 commented on Dec 12, 2025

    @kazo0
    Contributor

    @DevTKSS Merged! Please let me know if you are still seeing an issue with this change. The -dev package containing the fix should be available in a few hours

  8. DevTKSS commented on Dec 12, 2025

    @DevTKSS
    ContributorAuthor

    @kazo0 Thanks! finally no longer this is type of 'null' 🎉

    info: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          Selected https://platform.uno/platform/ in NavigationHistory
    warn: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          HistorySelectionChanged Got parameter: https://platform.uno/platform/, this is type of: Uri
    info: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          HistorySelectionChanged Selected Uri from CurrentUrl: https://platform.uno/platform/
    info: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          CurrentUrlChanged Adding https://platform.uno/studio/ to NavigationHistory
    info: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          Selected https://platform.uno/studio/ in NavigationHistory
    warn: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          HistorySelectionChanged Got parameter: https://platform.uno/studio/, this is type of: Uri
    info: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          HistorySelectionChanged Selected Uri from CurrentUrl: https://platform.uno/studio/
    warn: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          HistorySelectionChanged Got parameter: https://platform.uno/platform/, this is type of: Uri
    info: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          HistorySelectionChanged Selected Uri from CurrentUrl: https://platform.uno/platform/
    info: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          Url is already the current selected item in NavigationHistory, not adding duplicate.
    warn: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          HistorySelectionChanged Got parameter: https://platform.uno/studio/, this is type of: Uri
    info: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          HistorySelectionChanged Selected Uri from CurrentUrl: https://platform.uno/studio/
    info: DevTKSS.UnoWebView2App.Presentation.MainModel[0]
          Url is already the current selected item in NavigationHistory, not adding duplicate.
    

    Hoping the HD team will now check whats up with WebView2 in the latest Uno.Sdk Dev Build which doesn't show up any longer but at least resizes 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions