<commit_before>import React, { Component } from "react";
import PropTypes from "prop-types";
import { filterProps } from "../../helpers/functions";
import WithWrapper from "./_WithWrapper";

export class Textarea extends Component {
  static defaultProps = {
    value: ""
  };

  static propTypes = {
    /**
     * The initial value.
     */
    value: PropTypes.string,

    /**
     * The input name.
     */
    name: PropTypes.string
  };

  constructor(props) {
    super(props);

    this.state = {
      value: props.value
    };

    this.notify = this.notify.bind(this);
    this.handleChange = this.handleChange.bind(this);
    this.handleKeyUp = this.handleKeyUp.bind(this);
    this.handleBlur = this.handleBlur.bind(this);
  }

  /**
   * Sync the value.
   */
  componentWillReceiveProps(nextProps) {
    if (nextProps.value !== this.props.value) {
      this.setState({ value: nextProps.value });
    }
  }

  /**
   * Handle the change event.
   */
  handleChange(event) {
    this.setState({ value: event.target.value }, () => {
      this.changed = true;
    });
  }

  /**
   * Notify the parent of the change.
   */
  notify() {
    if (this.changed === true && typeof this.props.onChange === "function") {
      const { name, value } = this.props;
      this.props.onChange(this.state.value, {
        name,
        formValue: value,
        initialValue: value
      });
    }

    // Reset the value
    this.changed = false;
  }

  /**
   * Notify the parent when blur occurs.
   *
   * @param event
   */
  handleBlur(event) {
    this.notify();

    // istanbul ignore else
    if (typeof this.props.onBlur === "function") {
      this.props.onBlur(event);
    }
  }<commit_msg>Fix empty form value<commit_after>import React, { Component } from "react";
import PropTypes from "prop-types";
import { filterProps } from "../../helpers/functions";
import WithWrapper from "./_WithWrapper";

export class Textarea extends Component {
  static defaultProps = {
    value: ""
  };

  static propTypes = {
    /**
     * The initial value.
     */
    value: PropTypes.string,

    /**
     * The input name.
     */
    name: PropTypes.string
  };

  constructor(props) {
    super(props);

    this.state = {
      value: props.value
    };

    this.notify = this.notify.bind(this);
    this.handleChange = this.handleChange.bind(this);
    this.handleKeyUp = this.handleKeyUp.bind(this);
    this.handleBlur = this.handleBlur.bind(this);
  }

  /**
   * Sync the value.
   */
  componentWillReceiveProps(nextProps) {
    if (nextProps.value !== this.props.value) {
      this.setState({ value: nextProps.value });
    }
  }

  /**
   * Handle the change event.
   */
  handleChange(event) {
    this.setState({ value: event.target.value }, () => {
      this.changed = true;
    });
  }

  /**
   * Notify the parent of the change.
   */
  notify() {
    if (this.changed === true && typeof this.props.onChange === "function") {
      const { name, value } = this.props;
      this.props.onChange(this.state.value, {
        name,
        formValue: this.state.value,
        initialValue: value
      });
    }

    // Reset the value
    this.changed = false;
  }

  /**
   * Notify the parent when blur occurs.
   *
   * @param event
   */
  handleBlur(event) {
    this.notify();

    // istanbul ignore else
    if (typeof this.props.onBlur === "function") {
      this.props.onBlur(event);
    }
  }
{'fraction_non_alphanumeric': 0.1469387755102041, 'fraction_numerical': 0.0, 'mean_word_length': 2.273854961832061, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3082104', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1086, 'n_words': 235}