mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
Allow focus on the last character in Text Input (#65)
This commit is contained in:
parent
f6eea2f659
commit
ba7c2e9bb7
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user