Hi,
I experienced a strange problem today that I solved by defining a key for every
textarea in my code base (wrapping a Html.Keyed.node “div” around the text
area). What I specifically did is replaced all Html.textarea calls with a call
to:
safeTextarea : String -> List (Html.Attribute msg) -> List (Html.Html msg) ->
Html.Html msg
safeTextarea key attrs0 children =
let
attrs =
(name key) :: (id key) :: attrs0
in
Html.Keyed.node "div" [] [ ( key, textarea attrs children ) ]
Textarea DOM nodes have internal state and so making them keyed is not quite as
random as it sounds.
This is a little side project that I’ve been working on for a few months now,
it’s only about 2000 sloc. It’s been behaving just fine until this morning when
I made some change (I don’t know what, but I think it was adding a term to my
Msg type) and two text areas began sharing content. This happened in Chrome,
Safari, and Firefox. In all three cases inspecting the textarea showed the text
I expected, not the text that was displayed.
** This problem started with a change remote from the existing textareas, and
only affected two of eight or nine textareas **
I don’t think this is quite a reportable issue with elm, but maybe. If it is
then the fix is to require keyed textareas.
Cheers,
Bob
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.