elm / virtual-dom

The foundation of HTML and SVG in Elm.
https://package.elm-lang.org/packages/elm/virtual-dom/latest
BSD 3-Clause "New" or "Revised" License
209 stars 80 forks source link

cannot change content editable true\false dynamically #137

Closed setdvd closed 6 years ago

setdvd commented 6 years ago

Hi!

Trying to change contenteditable prop like this:

viewSticker: Bool -> Sticker -> Html Msg
viewSticker focused sticker =
        div
            [onDoubleClick (Focus sticker.id) contenteditable focused])
            [text sticker.value]

expected behavior: prop changes based on the focused value

actual behavior: contenteditable value stays same after the first render

Elm 0.19.0

setdvd commented 6 years ago

It looks like not an Elm issue

Example code:

module Playground exposing (..)

import Browser
import Html exposing (Html, div, text)
import Html.Events exposing (onClick)

main : Program () Model Msg
main =
  Browser.document
    { init = \_ -> (someText, Cmd.none)
    , view = view
    , update = update
    , subscriptions = subscriptions
    }

subscriptions : Model -> Sub Msg
subscriptions _ =
  Sub.none

someText = "someText"
otherText = "otherText"

type alias Model = String

type Msg = Click

update msg model =
    case model == someText of
        True -> (otherText, Cmd.none)
        False -> (someText, Cmd.none)

view: String -> Browser.Document Msg
view t =
        { title = "Playground"
        , body =
              [ div
                [onClick Click]
                [text (Debug.log "current text" t)]
              ]
        }

Doesn't work when Stay Focus Chrome plugin is enabled.

When I disable one - every start working as expected. One more note this is not reproduced in Browser.sandbox mode

evancz commented 6 years ago

The content editable stuff seems too wild for official support. I don't think we can give any guarantees about it at this time.