From ba7c2e9bb7ed493eb05fda844bb321aee30548bd Mon Sep 17 00:00:00 2001 From: Daniil Khanin Date: Sat, 23 Sep 2017 09:15:01 +0300 Subject: [PATCH] Allow focus on the last character in Text Input (#65) --- packages/react-bootstrap-table2/src/text-editor.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/react-bootstrap-table2/src/text-editor.js b/packages/react-bootstrap-table2/src/text-editor.js index 06c9cfe..285236d 100644 --- a/packages/react-bootstrap-table2/src/text-editor.js +++ b/packages/react-bootstrap-table2/src/text-editor.js @@ -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 ( 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;