mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
fix #527
This commit is contained in:
parent
7a1ed67847
commit
db19e7dd9b
@ -24,6 +24,7 @@ export default (_, onStartEdit) =>
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onEscape: PropTypes.func.isRequired,
|
||||
timeToCloseMessage: PropTypes.number,
|
||||
autoSelectText: PropTypes.bool,
|
||||
className: PropTypes.string,
|
||||
style: PropTypes.object
|
||||
}
|
||||
@ -31,6 +32,7 @@ export default (_, onStartEdit) =>
|
||||
static defaultProps = {
|
||||
timeToCloseMessage: TIME_TO_CLOSE_MESSAGE,
|
||||
className: null,
|
||||
autoSelectText: false,
|
||||
style: {}
|
||||
}
|
||||
|
||||
@ -121,7 +123,7 @@ export default (_, onStartEdit) =>
|
||||
|
||||
render() {
|
||||
let editor;
|
||||
const { row, column, className, style, rowIndex, columnIndex } = this.props;
|
||||
const { row, column, className, style, rowIndex, columnIndex, autoSelectText } = this.props;
|
||||
const { dataField } = column;
|
||||
|
||||
const value = _.get(row, dataField);
|
||||
@ -174,13 +176,13 @@ export default (_, onStartEdit) =>
|
||||
} else if (isDefaultEditorDefined && column.editor.type === EDITTYPE.SELECT) {
|
||||
editor = <DropdownEditor { ...editorProps } />;
|
||||
} else if (isDefaultEditorDefined && column.editor.type === EDITTYPE.TEXTAREA) {
|
||||
editor = <TextAreaEditor { ...editorProps } />;
|
||||
editor = <TextAreaEditor { ...editorProps } autoSelectText={ autoSelectText } />;
|
||||
} else if (isDefaultEditorDefined && column.editor.type === EDITTYPE.CHECKBOX) {
|
||||
editor = <CheckBoxEditor { ...editorProps } />;
|
||||
} else if (isDefaultEditorDefined && column.editor.type === EDITTYPE.DATE) {
|
||||
editor = <DateEditor { ...editorProps } />;
|
||||
} else {
|
||||
editor = <TextEditor { ...editorProps } />;
|
||||
editor = <TextEditor { ...editorProps } autoSelectText={ autoSelectText } />;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -5,9 +5,10 @@ import PropTypes from 'prop-types';
|
||||
|
||||
class TextEditor extends Component {
|
||||
componentDidMount() {
|
||||
const { defaultValue, didMount } = this.props;
|
||||
const { defaultValue, didMount, autoSelectText } = this.props;
|
||||
this.text.value = defaultValue;
|
||||
this.text.focus();
|
||||
if (autoSelectText) this.text.select();
|
||||
if (didMount) didMount();
|
||||
}
|
||||
|
||||
@ -16,7 +17,7 @@ class TextEditor extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { defaultValue, didMount, className, ...rest } = this.props;
|
||||
const { defaultValue, didMount, className, autoSelectText, ...rest } = this.props;
|
||||
const editorClass = cs('form-control editor edit-text', className);
|
||||
return (
|
||||
<input
|
||||
@ -38,11 +39,13 @@ TextEditor.propTypes = {
|
||||
PropTypes.string,
|
||||
PropTypes.number
|
||||
]),
|
||||
autoSelectText: PropTypes.bool,
|
||||
didMount: PropTypes.func
|
||||
};
|
||||
TextEditor.defaultProps = {
|
||||
className: null,
|
||||
defaultValue: '',
|
||||
autoSelectText: false,
|
||||
didMount: undefined
|
||||
};
|
||||
export default TextEditor;
|
||||
|
||||
@ -10,9 +10,10 @@ class TextAreaEditor extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { defaultValue, didMount } = this.props;
|
||||
const { defaultValue, didMount, autoSelectText } = this.props;
|
||||
this.text.value = defaultValue;
|
||||
this.text.focus();
|
||||
if (autoSelectText) this.text.select();
|
||||
if (didMount) didMount();
|
||||
}
|
||||
|
||||
@ -28,7 +29,7 @@ class TextAreaEditor extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { defaultValue, didMount, className, ...rest } = this.props;
|
||||
const { defaultValue, didMount, className, autoSelectText, ...rest } = this.props;
|
||||
const editorClass = cs('form-control editor edit-textarea', className);
|
||||
return (
|
||||
<textarea
|
||||
@ -52,11 +53,13 @@ TextAreaEditor.propTypes = {
|
||||
PropTypes.number
|
||||
]),
|
||||
onKeyDown: PropTypes.func,
|
||||
autoSelectText: PropTypes.bool,
|
||||
didMount: PropTypes.func
|
||||
};
|
||||
TextAreaEditor.defaultProps = {
|
||||
className: '',
|
||||
defaultValue: '',
|
||||
autoSelectText: false,
|
||||
onKeyDown: undefined,
|
||||
didMount: undefined
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user