Handle alt+enter in the spoiler input as shortcut for secondary post
Fixes #780
This commit is contained in:
		
							parent
							
								
									70d346ea95
								
							
						
					
					
						commit
						b0527a4ce7
					
				|  | @ -437,6 +437,7 @@ class Composer extends React.Component { | ||||||
|           intl={intl} |           intl={intl} | ||||||
|           onChange={handleChangeSpoiler} |           onChange={handleChangeSpoiler} | ||||||
|           onSubmit={handleSubmit} |           onSubmit={handleSubmit} | ||||||
|  |           onSecondarySubmit={handleSecondarySubmit} | ||||||
|           text={spoilerText} |           text={spoilerText} | ||||||
|           ref={handleRefSpoilerText} |           ref={handleRefSpoilerText} | ||||||
|         /> |         /> | ||||||
|  |  | ||||||
|  | @ -25,13 +25,19 @@ const handlers = { | ||||||
|     ctrlKey, |     ctrlKey, | ||||||
|     keyCode, |     keyCode, | ||||||
|     metaKey, |     metaKey, | ||||||
|  |     altKey, | ||||||
|   }) { |   }) { | ||||||
|     const { onSubmit } = this.props; |     const { onSubmit, onSecondarySubmit } = this.props; | ||||||
| 
 | 
 | ||||||
|     //  We submit the status on control/meta + enter.
 |     //  We submit the status on control/meta + enter.
 | ||||||
|     if (onSubmit && keyCode === 13 && (ctrlKey || metaKey)) { |     if (onSubmit && keyCode === 13 && (ctrlKey || metaKey)) { | ||||||
|       onSubmit(); |       onSubmit(); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     // Submit the status with secondary visibility on alt + enter.
 | ||||||
|  |     if (onSecondarySubmit && keyCode === 13 && altKey) { | ||||||
|  |       onSecondarySubmit(); | ||||||
|  |     } | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   handleRefSpoilerText (spoilerText) { |   handleRefSpoilerText (spoilerText) { | ||||||
|  | @ -87,5 +93,6 @@ ComposerSpoiler.propTypes = { | ||||||
|   intl: PropTypes.object.isRequired, |   intl: PropTypes.object.isRequired, | ||||||
|   onChange: PropTypes.func, |   onChange: PropTypes.func, | ||||||
|   onSubmit: PropTypes.func, |   onSubmit: PropTypes.func, | ||||||
|  |   onSecondarySubmit: PropTypes.func, | ||||||
|   text: PropTypes.string, |   text: PropTypes.string, | ||||||
| }; | }; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue