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

Html.Keyed.node does not preserve scroll positions across children #183

Open
pravdomil opened this issue Sep 19, 2022 · 0 comments
Open

Comments

@pravdomil
Copy link

pravdomil commented Sep 19, 2022

The __3_REORDER patch removes nodes from DOM and that causes scroll positions to reset.

I think that it can use only insertBefore function to preserve node state.

SSCCE

module Main exposing (..)

import Browser
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Html.Keyed


main : Program () Bool ()
main =
    Browser.sandbox
        { init = False
        , view = view
        , update = always not
        }


view : Bool -> Html ()
view model =
    div []
        [ Html.Keyed.node "div"
            []
            ([ content "A"
             , content "B"
             ]
                |> (\x ->
                        if model then
                            List.reverse x

                        else
                            x
                   )
            )
        , button [ onClick () ] [ text "Swap" ]
        ]


content a =
    ( a
    , div
        [ id a
        , style "overflow" "auto"
        , style "height" "100px"
        , style "width" "100px"
        , style "padding" "10px"
        , style "border" "1px solid blue"
        ]
        [ text (String.repeat 5000 (a ++ " "))
        ]
    )

related to #178

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