Skip to content

textarea_ function signature forces usage of controlled inputs #1496

Description

@mtamc

Describe the bug

As of a4fcfe8, the function signature for textarea_ is now textarea_ :: [Attribute action] -> MisoString -> View model action, where the second parameter being used for the textarea's value attribute.

-- | [\<textarea\>](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/textarea)
--
-- @
-- textarea_ [ id_ "txt" ] 
--    """
--    text goes here
--    """
-- @
--
-- @since 1.9.0.0
textarea_ :: [Attribute action] -> MisoString -> View model action
#ifdef VANILLA
textarea_ attrs txt = nodeHtml "textarea" attrs [ text txt ] 
#else
textarea_ attrs txt = nodeHtml "textarea" (textProp "value" txt : attrs) []
#endif

Passing in e.g. the empty string "" as parameter causes input to be wiped every keystroke:

textarea_new_fn_signature_bug-2026-04-13_17.43.19.webm

This leaves us forced to use a controlled input (passing in this parameter as the value we hold in the component Model), which has the very problematic bug #272 - further repro steps in my comment, but I'll repost the video demo:

textarea_cursor_bug-2026-04-13_16.53.23.webm

Some useful leads on how Elm fixed their equivalent of #272 : elm/virtual-dom#138 (comment)

Other thread with potential fixes and workarounds: elm/html#105 (comment)

To Reproduce

  • Insert a textarea_ with the empty string as its second argument
  • Try typing, input gets wiped every character
  • Insert a textarea_ with the Model field where you store user input as the textarea_'s second argument
  • Try typing fast in the middle of existing input, the cursor gets teleported to the end of the textarea

Expected behavior

  • Restore user choice between controlled and uncontrolled inputs

AND/OR

  • Fix controlled input bug where typing fast in the middle of existing text causes the cursor to jump to the end of the textarea

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser: Chrome, Firefox, Vivaldi
  • Version: Chrome 137.0.7151.119, Firefox 149.0.2, Vivaldi 7.3.3635.12

Smartphone (please complete the following information):
Not tested

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions