@ -83,11 +83,23 @@ const ComposeForm = React.createClass({
this . props . onChangeSpoilerText ( e . target . value ) ;
this . props . onChangeSpoilerText ( e . target . value ) ;
} ,
} ,
componentWillReceiveProps ( nextProps ) {
/ / I f t h i s i s t h e u p d a t e w h e r e w e ' v e f i n i s h e d u p l o a d i n g ,
/ / s a v e t h e l a s t c a r e t p o s i t i o n s o w e c a n r e s t o r e i t b e l o w !
if ( ! nextProps . is _uploading && this . props . is _uploading ) {
this . _restoreCaret = this . autosuggestTextarea . textarea . selectionStart ;
}
} ,
componentDidUpdate ( prevProps ) {
componentDidUpdate ( prevProps ) {
if ( this . props . focusDate !== prevProps . focusDate ) {
/ / T h i s s t a t e m e n t d o e s s e v e r a l t h i n g s :
/ / I f r e p l y i n g t o z e r o o r o n e u s e r s , p l a c e s t h e c u r s o r a t t h e e n d o f t h e t e x t b o x .
/ / - I f w e ' r e b e g i n n i n g a r e p l y , a n d ,
/ / I f r e p l y i n g t o m o r e t h a n o n e u s e r , s e l e c t s a n y u s e r n a m e s p a s t t h e f i r s t ;
/ / - R e p l y i n g t o z e r o o r o n e u s e r s , p l a c e s t h e c u r s o r a t t h e e n d o f t h e t e x t b o x .
/ / - R e p l y i n g t o m o r e t h a n o n e u s e r , s e l e c t s a n y u s e r n a m e s p a s t t h e f i r s t ;
/ / t h i s p r o v i d e s a c o n v e n i e n t s h o r t c u t t o d r o p e v e r y o n e e l s e f r o m t h e c o n v e r s a t i o n .
/ / t h i s p r o v i d e s a c o n v e n i e n t s h o r t c u t t o d r o p e v e r y o n e e l s e f r o m t h e c o n v e r s a t i o n .
/ / - I f w e ' v e j u s t f i n i s h e d u p l o a d i n g a n i m a g e , a n d h a v e a s a v e d c a r e t p o s i t i o n ,
/ / r e s t o r e s t h e c u r s o r t o t h a t p o s i t i o n a f t e r t h e t e x t c h a n g e s !
if ( this . props . focusDate !== prevProps . focusDate || ( prevProps . is _uploading && ! this . props . is _uploading && typeof this . _restoreCaret === 'number' ) ) {
let selectionEnd , selectionStart ;
let selectionEnd , selectionStart ;
if ( this . props . preselectDate !== prevProps . preselectDate ) {
if ( this . props . preselectDate !== prevProps . preselectDate ) {
@ -118,7 +130,7 @@ const ComposeForm = React.createClass({
render ( ) {
render ( ) {
const { intl , needsPrivacyWarning , mentionedDomains , onPaste } = this . props ;
const { intl , needsPrivacyWarning , mentionedDomains , onPaste } = this . props ;
const disabled = this . props . is _submitting || this . props . is _uploading ;
const disabled = this . props . is _submitting ;
let publishText = '' ;
let publishText = '' ;
let privacyWarning = '' ;
let privacyWarning = '' ;