Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
scalajs-react: How to have multiline text field from a Seq in state object?

I am working in a scalajs-react application. One of the UI field I have is an input field for multiline text, and it is mapped to a property of state object. State object definition:

case class Person(name: String, addresses: Seq[String])

I have corresponding UI field for addresses as:

 <.label("Addresses:",
              <.input(^.`type` := "text", ^.cls := "form-control",
                ^.value := person.addresses.mkString("\n"), ^.onChange ==> updateAddresses))

def updateAddresses(event: ReactEventFromInput): Callback = {
    val updatedAddresses = event.target.value.split("\\\\n").toSeq // based on some google search
    $.modState(prev => prev.copy(addresses = updatedAddresses))
  }

But seems it doesn't work. I am not able to add a newline entry on UI.

How can it be achieved?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have to you textarea html tag for multiline text input. (see https://www.w3schools.com/tags/tag_textarea.asp)

This works:

<.label("Addresses:",
          <.textarea(^.`type` := "text", ^.cls := "form-control",
            ^.value := person.addresses.mkString("\n"), ^.onChange ==> updateAddresses))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!