<commit_before>import React, { Component } from 'react';
import { Form, Label } from 'semantic-ui-react';


class MetricTarget extends Component {
  constructor(props) {
    super(props);
    this.state = { edited_target: this.props.target || 0 }
  }
  onChange(event) {
    this.setState({ edited_target: event.target.value});
  }
  onKeyDown(event) {
    if (event.key === "Escape") {
      this.setState({ edited_target: this.props.target })
    }
  }
  onSubmit(event) {
    event.preventDefault();
    if (this.state.edited_target !== this.props.target) {
      this.props.set_value(this.state.edited_target || 0);
    }
  }
  render() {
    return (
      <Form onSubmit={(e) => this.onSubmit(e)}>
        <Form.Group style={{marginBottom: '0px'}}>
          <Form.Input
            focus
            label={this.props.label}
            labelPosition='right'
            min="0"
            type="number"
            onBlur={(e) => this.onSubmit(e)}
            onChange={(e) => this.onChange(e)}
            onKeyDown={(e) => this.onKeyDown(e)}
            readOnly={this.props.readOnly}
            value={this.state.edited_target}
            width={16}<commit_msg>Update the metric target field when changing the metric type. (#179)<commit_after>import React, { Component } from 'react';
import { Form, Label } from 'semantic-ui-react';


class MetricTarget extends Component {
  constructor(props) {
    super(props);
    this.state = { edited_target: this.props.target || 0 }
  }
  componentDidUpdate(prevProps) {
    if (prevProps.target !== this.props.target) {
      this.setState({ edited_target: this.props.target })
    }
  }
  onChange(event) {
    this.setState({ edited_target: event.target.value});
  }
  onKeyDown(event) {
    if (event.key === "Escape") {
      this.setState({ edited_target: this.props.target })
    }
  }
  onSubmit(event) {
    event.preventDefault();
    if (this.state.edited_target !== this.props.target) {
      this.props.set_value(this.state.edited_target || 0);
    }
  }
  render() {
    return (
      <Form onSubmit={(e) => this.onSubmit(e)}>
        <Form.Group style={{marginBottom: '0px'}}>
          <Form.Input
            focus
            label={this.props.label}
            labelPosition='right'
            min="0"
            type="number"
            onBlur={(e) => this.onSubmit(e)}
            onChange={(e) => this.onChange(e)}
            onKeyDown={(e) => this.onKeyDown(e)}
            readOnly={this.props.readOnly}
            value={this.state.edited_target}
            width={16}
{'fraction_non_alphanumeric': 0.15330465389127884, 'fraction_numerical': 0.005866249511145874, 'mean_word_length': 2.4335570469798657, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '397244', 'n_tokens_mistral': 819, 'n_tokens_neox': 812, 'n_words': 138}