@@ -58,7 +58,9 @@ const ImageMimeRegex = /image\//i;
5858export class CommentForm extends Component < Props , State > {
5959 /** reference to textarea element */
6060 textareaRef = createRef < HTMLTextAreaElement > ( ) ;
61- static textareaId = 0 ;
61+ static textareaCounter = 0 ;
62+ /** unique textarea ID for this instance */
63+ textareaId : string ;
6264
6365 state = {
6466 preview : null ,
@@ -75,7 +77,8 @@ export class CommentForm extends Component<Props, State> {
7577
7678 const savedComment = getPersistedComment ( props . id ) ;
7779 this . state . text = props . value ?? savedComment ?? '' ;
78- CommentForm . textareaId += 1 ;
80+ CommentForm . textareaCounter += 1 ;
81+ this . textareaId = `textarea_${ CommentForm . textareaCounter } ` ;
7982 }
8083
8184 componentWillReceiveProps ( nextProps : Props ) {
@@ -416,7 +419,6 @@ export class CommentForm extends Component<Props, State> {
416419 edit : < FormattedMessage id = "commentForm.save" defaultMessage = "Save" /> ,
417420 reply : < FormattedMessage id = "commentForm.reply" defaultMessage = "Reply" /> ,
418421 } ;
419- const textareaId = `textarea_${ CommentForm . textareaId } ` ;
420422 const label = buttonText || Labels [ mode || 'main' ] ;
421423 const placeholderMessage = intl . formatMessage ( messages . placeholder ) ;
422424 const isSimpleView = StaticStore . config . simple_view ;
@@ -443,14 +445,14 @@ export class CommentForm extends Component<Props, State> {
443445 intl = { intl }
444446 allowUpload = { Boolean ( uploadImage ) }
445447 uploadImages = { this . uploadImages }
446- textareaId = { textareaId }
448+ textareaId = { this . textareaId }
447449 />
448450 </ div >
449451 ) }
450452 < div className = "comment-form__field-wrapper" >
451453 < TextExpander >
452454 < TextareaAutosize
453- id = { textareaId }
455+ id = { this . textareaId }
454456 ref = { this . textareaRef }
455457 onPaste = { this . onPaste }
456458 className = "comment-form__field"
0 commit comments