Skip to content

Commit dc35f6d

Browse files
ur300paskal
authored andcommitted
1833 - Toolbar buttons are stuck to the main comment form
1 parent 564e8ff commit dc35f6d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

frontend/apps/remark42/app/components/comment-form/comment-form.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function setup(overrideProps: Partial<Props> = {}, overrideConfig: Partial<typeo
4040
describe('<CommentForm />', () => {
4141
afterEach(() => {
4242
// reset textarea id in order to have `textarea_1` for every test
43-
CommentForm.textareaId = 0;
43+
CommentForm.textareaCounter = 0;
4444
localStorage.clear();
4545
});
4646

frontend/apps/remark42/app/components/comment-form/comment-form.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ const ImageMimeRegex = /image\//i;
5858
export 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

Comments
 (0)