<commit_before>import * as React from "react";
import { SurveyQuestionUncontrolledElement } from "./reactquestion_element";
import { QuestionTextModel } from "../question_text";
import { ReactQuestionFactory } from "./reactquestion_factory";

export class SurveyQuestionText extends SurveyQuestionUncontrolledElement<
  QuestionTextModel
> {
  constructor(props: any) {
    super(props);
  }
  protected renderElement(): JSX.Element {
    var cssClasses = this.question.cssClasses;
    var onBlur = !this.question.isInputTextUpdate
      ? this.updateValueOnEvent
      : null;
    var onInput = this.question.isInputTextUpdate
      ? this.updateValueOnEvent
      : null;
    var placeHolder =
      this.question.inputType === "range" || this.question.isReadOnly
        ? ""
        : this.question.placeHolder;
    return (
      <input
        id={this.question.inputId}
        disabled={this.isDisplayMode}
        className={cssClasses.root}
        type={this.question.inputType}
        ref={(input) => (this.control = input)}
        maxLength={this.question.getMaxLength()}
        min={this.question.renderedMin}
        max={this.question.renderedMax}
        step={this.question.step}
        size={this.question.size}
        placeholder={placeHolder}
        autoComplete={this.question.autoComplete}
        onBlur={onBlur}
        onInput={onInput}
        aria-required={this.question.isRequired}
        aria-label={this.question.locTitle.renderedHtml}
        aria-invalid={this.question.errors.length > 0}
        aria-describedby={
          this.question.errors.length > 0 ? this.question.id + "_errors" : null
        }
      />
    );
  }
}

ReactQuestionFactory.Instance.registerQuestion("text", (props) => {
  return React.createElement(SurveyQuestionText, props);
});<commit_msg>Fixed #2584 - Key chatter if multibyte symbol<commit_after>import * as React from "react";
import { SurveyQuestionUncontrolledElement } from "./reactquestion_element";
import { QuestionTextModel } from "../question_text";
import { ReactQuestionFactory } from "./reactquestion_factory";

export class SurveyQuestionText extends SurveyQuestionUncontrolledElement<
  QuestionTextModel
> {
  private _isWaitingForEnter = false;
  constructor(props: any) {
    super(props);
  }
  protected renderElement(): JSX.Element {
    var cssClasses = this.question.cssClasses;
    var onBlur = !this.question.isInputTextUpdate
      ? this.updateValueOnEvent
      : null;
    var onKeyDown = null;
    var onKeyUp = null;
    if(this.question.isInputTextUpdate) {
      onKeyDown = (e: any) => this._isWaitingForEnter = (e.keyCode === 229);
      onKeyUp = (e: any) => {
        if(!this._isWaitingForEnter || (e.keyCode === 13)) {
          this.updateValueOnEvent(e);
          this._isWaitingForEnter = false;
        }
      }
    }
    var placeHolder =
      this.question.inputType === "range" || this.question.isReadOnly
        ? ""
        : this.question.placeHolder;
    return (
      <input
        id={this.question.inputId}
        disabled={this.isDisplayMode}
        className={cssClasses.root}
        type={this.question.inputType}
        ref={(input) => (this.control = input)}
        maxLength={this.question.getMaxLength()}
        min={this.question.renderedMin}
        max={this.question.renderedMax}
        step={this.question.step}
        size={this.question.size}
        placeholder={placeHolder}
        autoComplete={this.question.autoComplete}
        onBlur={onBlur}
        // onChange={this.updateValueOnEvent}
        onKeyUp={onKeyUp}
        onKeyDown={onKeyDown}
        aria-required={this.question.isRequired}
        aria-label={this.question.locTitle.renderedHtml}
        aria-invalid={this.question.errors.length > 0}
        aria-describedby={
          this.question.errors.length > 0 ? this.question.id + "_errors" : null
        }
      />
    );
  }
}

ReactQuestionFactory.Instance.registerQuestion("text", (props) => {
  return React.createElement(SurveyQuestionText, props);
});
{'fraction_non_alphanumeric': 0.12193308550185873, 'fraction_numerical': 0.00322180916976456, 'mean_word_length': 2.968534906588004, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '7128281', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1151, 'n_words': 190}