<commit_before>import React, {PropTypes} from 'react';
import Draggable from './Draggable';

export default class Knob extends React.Component {

  static propTypes = {
    onChange: PropTypes.func,
    onDone: PropTypes.func,
    onStart: PropTypes.func
  };

  static defaultProps = {
    x: 0,
    y: 0
  };

  static contextTypes = {
    api: PropTypes.object,
    matrix: PropTypes.object
  };

  handleStartDrag = (e) => {
    document.activeElement.blur();
    e.nativeEvent.preventDefault();
    this.relativeStartPoint = e.relativeStartPoint;
    this.context.api.startChange();
    this.props.onStart && this.props.onStart();
  };

  handleDrag = (e) => {
    e.relativePoint.x -= this.relativeStartPoint.x;
    e.relativePoint.y -= this.relativeStartPoint.y;

    this.props.onChange && this.props.onChange(this, e.relativePoint);
  };

  handleDragEnd = (e) => {
    e.nativeEvent.stopPropagation();
    this.context.api.finishChange();
    this.props.onDone && this.props.onDone();
  };
<commit_msg>fix blur/focus when using Knob<commit_after>import React, {PropTypes} from 'react';
import Draggable from './Draggable';

export default class Knob extends React.Component {

  static propTypes = {
    onChange: PropTypes.func,
    onDone: PropTypes.func,
    onStart: PropTypes.func
  };

  static defaultProps = {
    x: 0,
    y: 0
  };

  static contextTypes = {
    api: PropTypes.object,
    matrix: PropTypes.object
  };

  handleStartDrag = (e) => {
    this.activeElement = document.activeElement;
    this.activeElement && this.activeElement.blur();

    e.nativeEvent.preventDefault();
    this.relativeStartPoint = e.relativeStartPoint;
    this.context.api.startChange();
    this.props.onStart && this.props.onStart();
  };

  handleDrag = (e) => {
    e.relativePoint.x -= this.relativeStartPoint.x;
    e.relativePoint.y -= this.relativeStartPoint.y;

    this.props.onChange && this.props.onChange(this, e.relativePoint);
  };

  handleDragEnd = (e) => {
    this.activeElement && this.activeElement.focus();

    e.nativeEvent.stopPropagation();
    this.context.api.finishChange();
    this.props.onDone && this.props.onDone();
  };

{'fraction_non_alphanumeric': 0.13863216266173753, 'fraction_numerical': 0.0018484288354898336, 'mean_word_length': 3.312749003984064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2581788', 'n_tokens_mistral': 699, 'n_tokens_neox': 692, 'n_words': 127}