Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix focus on the Last Character in Text Input
  • Loading branch information
khaninD committed Sep 20, 2017
commit bf63b9bf93ea6766c1e0c960dd64d7036cc1ee84
12 changes: 11 additions & 1 deletion packages/react-bootstrap-table2/src/text-editor.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
/* eslint no-return-assign: 0 */
import React, { Component } from 'react';
import PropTypes from 'prop-types';

class TextEditor extends Component {
componentDidMount() {
const { defaultValue } = this.props;
this.text.value = defaultValue;
this.text.focus();
}

render() {
const { defaultValue, ...rest } = this.props;
return (
<input
ref={ node => this.text = node }
type="text"
className="form-control editor edit-text"
{ ...this.props }
{ ...rest }
/>
);
}
}

TextEditor.propTypes = {
defaultValue: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]).isRequired
};
export default TextEditor;