@@ -39,6 +39,7 @@ const Textarea = props => {
3939 spellcheck,
4040 tabIndex,
4141 tabindex,
42+ submit_on_enter,
4243 ...otherProps
4344 } = props ;
4445 const [ valueState , setValueState ] = useState ( value || '' ) ;
@@ -71,7 +72,7 @@ const Textarea = props => {
7172 } ;
7273
7374 const onKeyPress = e => {
74- if ( setProps && e . key === 'Enter' && ! e . shiftKey ) {
75+ if ( submit_on_enter && setProps && e . key === 'Enter' && ! e . shiftKey ) {
7576 e . preventDefault ( ) ; // don't create newline if submitting
7677 const payload = {
7778 n_submit : n_submit + 1 ,
@@ -404,15 +405,22 @@ Textarea.propTypes = {
404405 n_blur_timestamp : PropTypes . number ,
405406
406407 /**
407- * Number of times the `Enter` key was pressed while the textarea had focus.
408+ * Number of times the `Enter` key was pressed while the textarea had focus. Only
409+ * updates if submit_on_enter is True.
408410 */
409411 n_submit : PropTypes . number ,
410412
411413 /**
412- * Last time that `Enter` was pressed.
414+ * Last time that `Enter` was pressed. Only updates if submit_on_enter is True.
413415 */
414416 n_submit_timestamp : PropTypes . number ,
415417
418+ /**
419+ * Whether or not the form should increment the n_submit and n_submit_timestamp props
420+ * when enter key is pressed. If True, use shift + enter to create a newline. Default: True
421+ */
422+ submit_on_enter : PropTypes . bool ,
423+
416424 /**
417425 * An integer that represents the number of times
418426 * that this element has been clicked on.
@@ -490,7 +498,8 @@ Textarea.defaultProps = {
490498 debounce : false ,
491499 persisted_props : [ 'value' ] ,
492500 persistence_type : 'local' ,
493- value : ''
501+ value : '' ,
502+ submit_on_enter : true
494503} ;
495504
496505export default Textarea ;
0 commit comments