Sha256: b8c642335ab035476534dc4c19436575dd2df977c432b2dd468b817032048108

Contents?: true

Size: 1002 Bytes

Versions: 70

Compression:

Stored size: 1002 Bytes

Contents

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormControl } from 'patternfly-react';

class TypeAheadInput extends Component {
  constructor(props) {
    super(props);
    this.handleKeyPress = this.handleKeyPress.bind(this);
  }

  componentDidMount() {
    if (this.ref) {
      this.ref.addEventListener('keydown', this.handleKeyPress);
    }
  }

  componentWillUnmount() {
    if (this.ref) {
      this.ref.removeEventListener('keydown', this.handleKeyPress);
    }
  }

  handleKeyPress(e) {
    this.props.onKeyPress(e);
  }

  render() {
    return (
      <FormControl
        inputRef={(ref) => {
          this.ref = ref;
        }}
        onFocus={this.props.onInputFocus}
        type="text"
        {...this.props.passedProps}
      />
    );
  }
}

TypeAheadInput.propTypes = {
  passedProps: PropTypes.shape({}).isRequired,
  onKeyPress: PropTypes.func.isRequired,
  onInputFocus: PropTypes.func.isRequired,
};

export default TypeAheadInput;

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
katello-3.16.2 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.1.2 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.1.1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0.rc5.1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0.rc5 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0.rc4.1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.15.3.1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.15.3 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0.rc4 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0.rc3.1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.15.2 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0.rc3 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0.rc2.1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0.rc2 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.15.1.1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0.rc1.1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.15.1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js
katello-3.16.0.rc1 webpack/move_to_pf/TypeAhead/TypeAheadInput.js