<commit_before>package io.youi.hypertext

import reactify.Var
import io.youi.dom
import io.youi.hypertext.style.FontProperties
import org.scalajs.dom.html.{Input => HTMLInput}

class TextInput extends Component {
  override protected[youi] val element: HTMLInput = dom.create[HTMLInput]("input")

  lazy val value: Var[String] = prop(element.value, _ => changed(), mayCauseResize = false)
  val font: FontProperties = new FontProperties(this)

  init()

  event.change.attach { _ =>
    changing = true
    try {
      value := element.value
    } finally {
      changing = false
    }
  }

  private var changing = false
  private def changed(): Unit = if (!changing) {
    changing = true
    try {
      element.value = value()
    } finally {
      changing = false
    }
  }
}<commit_msg>Fixed TextInput to update value on keystroke.<commit_after>package io.youi.hypertext

import reactify.Var
import io.youi.dom
import io.youi.hypertext.style.FontProperties
import org.scalajs.dom.html.{Input => HTMLInput}

class TextInput extends Component {
  override protected[youi] val element: HTMLInput = dom.create[HTMLInput]("input")

  lazy val value: Var[String] = prop(element.value, _ => changed(), mayCauseResize = false)
  val font: FontProperties = new FontProperties(this)

  init()

  event.change.attach { _ =>
    checkValue()
  }
  event.key.up.attach { _ =>
    checkValue()
  }

  private var changing = false
  private def changed(): Unit = if (!changing) {
    changing = true
    try {
      element.value = value()
    } finally {
      changing = false
    }
  }

  private def checkValue(): Unit = {
    val v = element.value
    if (value() != v && !changing) {
      changing = true
      try {
        value := v
      } finally {
        changing = false
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.11457174638487208, 'fraction_numerical': 0.0, 'mean_word_length': 2.9108695652173915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5445822', 'n_tokens_mistral': 555, 'n_tokens_neox': 545, 'n_words': 144}