<commit_before>/**
 * @file
 *
 * @brief simple editable text field for tree items
 *
 * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
 */

import React, { Component } from 'react'

import TextField from 'material-ui/TextField'

import validateType from './validateType'
import debounce from '../../debounce'
import { fromElektraBool } from '../../../utils'

const DebouncedTextField = debounce(TextField, { timeout: 1500 })

export default class SimpleTextField extends Component {
  constructor (props) {
    super(props)
    this.state = { value: props.value || '', error: false }
  }

  componentWillReceiveProps (nextProps) {
    if (nextProps.value && nextProps.value !== this.props.value) {
      console.log('next value', nextProps.value)
      this.setState({ value: nextProps.value })
    }
  }

  render () {
    const { id, meta, label, debounce = true, onChange, onError } = this.props
    const val = this.state.value
    const comp = debounce ? DebouncedTextField : TextField
    const isBinary = meta && meta.hasOwnProperty('binary')<commit_msg>web-ui: sync text field state properly<commit_after>/**
 * @file
 *
 * @brief simple editable text field for tree items
 *
 * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
 */

import React, { Component } from 'react'

import TextField from 'material-ui/TextField'

import validateType from './validateType'
import debounce from '../../debounce'
import { fromElektraBool } from '../../../utils'

const DebouncedTextField = debounce(TextField, { timeout: 1500 })

export default class SimpleTextField extends Component {
  constructor (props) {
    super(props)
    this.state = { value: props.value || '', error: false }
  }

  componentWillReceiveProps (nextProps) {
    if (nextProps.value !== this.props.value) {
      this.setState({ value: nextProps.value })
    }
  }

  render () {
    const { id, meta, label, debounce = true, onChange, onError } = this.props
    const val = this.state.value
    const comp = debounce ? DebouncedTextField : TextField
    const isBinary = meta && meta.hasOwnProperty('binary')
{'fraction_non_alphanumeric': 0.12976022566995768, 'fraction_numerical': 0.0037611659614480487, 'mean_word_length': 3.556745182012848, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '7489125', 'n_tokens_mistral': 620, 'n_tokens_neox': 611, 'n_words': 182}