Skip to content
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

Doc.SelectDynOptional loses the selection #1083

Closed
giuliohome opened this issue Dec 9, 2019 · 1 comment
Closed

Doc.SelectDynOptional loses the selection #1083

giuliohome opened this issue Dec 9, 2019 · 1 comment

Comments

@giuliohome
Copy link

As discussed with @amieres in gitter channel and as shown also by his mock-up repro, Doc.SelectDynOptional loses the selection after updating the options of a dropdown, unless the selected value is in the first position of the list.
My basic mock-up is shown below

namespace Samples

open WebSharper
open WebSharper.JavaScript
open WebSharper.UI
open WebSharper.UI.Html
open WebSharper.UI.Client
open WebSharper.UI.Notation

[<JavaScript>]
module HelloWorld =
    
    let getUsers() = async {
            do! Async.Sleep 100
            return Result.Ok ["you"; "me"; ]
        }

    let Main =
        let lineAssignedTo = "me"
        let assignedTo = Option.ofObj lineAssignedTo 
        let assignedVar = Var.Create<string option> assignedTo
        let users =  
            assignedTo 
            |> Option.fold (fun _ x -> [x]) []
            |> Var.Create<string list>
        async {
            match! getUsers() with
            | Result.Error error -> Console.Log error
            | Result.Ok dbusers -> 
                users.Set dbusers
        } |> Async.StartImmediate
        div [] [
            Doc.SelectDynOptional [] 
                 "No one assigned" id users.View assignedVar
        ]
        |> Doc.RunById "main"

The problem is that, after 100 ms, the command users.Set dbusers updates the users.View of the dropdown as expected, but the effect of the assignedVar is lost.

@giuliohome
Copy link
Author

giuliohome commented Dec 10, 2019

I need to open this in W# UI

Opened here

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

No branches or pull requests

1 participant