<commit_before>import React from 'react'
import PropTypes from 'prop-types'
import Button from '../../components/button/Button'
import DocumentIcon from '../../icons/StrokeDocument'
import FolderIcon from '../../icons/StrokeFolder'
import DecentralizationIcon from '../../icons/StrokeDecentralization'
import {Dropdown, DropdownMenu} from '@tableflip/react-dropdown'
import Overlay from '../../components/overlay/Overlay'
import ByPathModal from './ByPathModal'

export default class FileInput extends React.Component {
  static propTypes = {
    onAddFiles: PropTypes.func.isRequired,
    onAddByPath: PropTypes.func.isRequired
  }

  state = {
    dropdown: false,
    modal: false
  }

  toggleDropdown = () => {
    this.setState(s => ({ dropdown: !s.dropdown }))
  }

  toggleModal = () => {
    this.setState(s => ({ modal: !s.modal }))
  }

  onInputChange = (input) => () => {
    this.props.onAddFiles(input.files)
    input.value = null
    this.toggleDropdown()
  }

  onAddByPath = (path) => {
    this.props.onAddByPath(path)
    this.toggleModal()
  }

  render () {
    return (<commit_msg>fix: close dropdown when opening add by path modal<commit_after>import React from 'react'
import PropTypes from 'prop-types'
import Button from '../../components/button/Button'
import DocumentIcon from '../../icons/StrokeDocument'
import FolderIcon from '../../icons/StrokeFolder'
import DecentralizationIcon from '../../icons/StrokeDecentralization'
import {Dropdown, DropdownMenu} from '@tableflip/react-dropdown'
import Overlay from '../../components/overlay/Overlay'
import ByPathModal from './ByPathModal'

export default class FileInput extends React.Component {
  static propTypes = {
    onAddFiles: PropTypes.func.isRequired,
    onAddByPath: PropTypes.func.isRequired
  }

  state = {
    dropdown: false,
    modal: false
  }

  toggleDropdown = () => {
    this.setState(s => ({ dropdown: !s.dropdown }))
  }

  toggleModal = () => {
    if (!this.state.modal) {
      this.toggleDropdown()
    }

    this.setState(s => ({ modal: !s.modal }))
  }

  onInputChange = (input) => () => {
    this.props.onAddFiles(input.files)
    input.value = null
    this.toggleDropdown()
  }

  onAddByPath = (path) => {
    this.props.onAddByPath(path)
    this.toggleModal()
  }

  render () {
    return (
{'fraction_non_alphanumeric': 0.1449588922544353, 'fraction_numerical': 0.0, 'mean_word_length': 3.345864661654135, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5429687', 'n_tokens_mistral': 716, 'n_tokens_neox': 716, 'n_words': 159}