virtual-dom
virtual-dom copied to clipboard
Html.Keyed.node does not preserve scroll positions across children
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