<commit_before>import React from 'react';
import TimeLabel from './TimeLabel'
import GanttItem from './GanttItem';
import ItemController from '../control/ItemController'

export default class extends React.Component{
  constructor(props) {
    super(props)
    this.state = {
      selected: null
    }
  }

  render() {
    const items = (this.props.items||[]).map((item, index) => (
      <ItemController
        template={GanttItem}
        key={item.id}
        item={item}
        selected={this.state.selected === index}
        onSubmit={this.props.onEditItem}
        onClick={()=>this.setState({selected: index})}
      >
        {item.name}
      </ItemController>
    ));
    return (
      <div className="viewGroup" onKeyDown={this.onKeyDown}>
        <TimeLabel min="0" max="15" interval="5" unit="h">{this.props.children}</TimeLabel>
        {items}
        <ItemController
          template={GanttItem}
          className="placeholder"
          onSubmit={this.props.onInsertItem}
          selected={this.state.selected === this.props.items.length}
          onClick={()=>this.setState({selected: this.props.items.length})}
          placeholder="Add New Task"
        />
      </div>
    );
  }

  onKeyDown = (ev) => {
    switch (ev.key) {
      case 'ArrowUp':
        this.setState({selected: Math.max(0, (this.state.selected||1) -1)})
        break;
      case 'ArrowDown':
        this.setState({selected: Math.min(this.props.items.length, (this.state.selected +1)||0)})
        break;
      default:
        console.log(ev.key);
        break;
    }
  }
}<commit_msg>Added a way to handle focus changes<commit_after>import React from 'react';
import TimeLabel from './TimeLabel'
import GanttItem from './GanttItem';
import ItemController from '../control/ItemController'

export default class extends React.Component{
  constructor(props) {
    super(props)
    this.state = {
      selected: null
    }
  }

  render() {
    const items = (this.props.items||[]).map((item, index) => (
      <ItemController
        template={GanttItem}
        key={item.id}
        item={item}
        selected={this.state.selected === index}
        onSubmit={this.props.onEditItem}
        onClick={this.onClickItem.bind(this, index)}
      >
        {item.name}
      </ItemController>
    ));
    const length = this.props.items.length;
    return (
      <div
        className="viewGroup"
        onKeyDown={this.onKeyDown}
        onClick={this.onClick}
      >
        <TimeLabel min="0" max="15" interval="5" unit="h">{this.props.children}</TimeLabel>
        {items}
        <ItemController
          template={GanttItem}
          className="placeholder"
          onSubmit={this.props.onInsertItem}
          selected={this.state.selected === length}
          onClick={this.onClickItem.bind(this, length)}
          placeholder="Add New Task"
        />
      </div>
    );
  }

  onClickItem(index, ev){
    this.setState({selected: index});
    ev.stopPropagation();
  }

  onClick = (ev) => {
    this.setState({selected: null});
  }

  onKeyDown = (ev) => {
    switch (ev.key) {
      case 'ArrowUp':
        this.setState({selected: Math.max(0, (this.state.selected||1) -1)})
        break;
      case 'ArrowDown':
        this.setState({selected: Math.min(this.props.items.length, (this.state.selected +1)||0)})
        break;
      default:
        console.log(ev.key);
        break;
    }
  }
}
{'fraction_non_alphanumeric': 0.15193934091571887, 'fraction_numerical': 0.005249343832020997, 'mean_word_length': 2.396039603960396, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 24, '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': '3584557', 'n_tokens_mistral': 1048, 'n_tokens_neox': 1056, 'n_words': 189}