@@ -16,6 +16,7 @@ export class PageComments extends Component {
|
16 | 16 | private archivedTab!: HTMLElement;
|
17 | 17 | private addButtonContainer!: HTMLElement;
|
18 | 18 | private archiveContainer!: HTMLElement;
|
| 19 | +private activeContainer!: HTMLElement; |
19 | 20 | private replyToRow!: HTMLElement;
|
20 | 21 | private referenceRow!: HTMLElement;
|
21 | 22 | private formContainer!: HTMLElement;
|
@@ -48,6 +49,7 @@ export class PageComments extends Component {
|
48 | 49 | this.archivedTab = this.$refs.archivedTab;
|
49 | 50 | this.addButtonContainer = this.$refs.addButtonContainer;
|
50 | 51 | this.archiveContainer = this.$refs.archiveContainer;
|
| 52 | +this.activeContainer = this.$refs.activeContainer; |
51 | 53 | this.replyToRow = this.$refs.replyToRow;
|
52 | 54 | this.referenceRow = this.$refs.referenceRow;
|
53 | 55 | this.formContainer = this.$refs.formContainer;
|
@@ -76,8 +78,10 @@ export class PageComments extends Component {
|
76 | 78 |
|
77 | 79 | protected setupListeners(): void {
|
78 | 80 | this.elem.addEventListener('page-comment-delete', () => {
|
79 |
| -setTimeout(() => this.updateCount(), 1); |
80 |
| -this.hideForm(); |
| 81 | +setTimeout(() => { |
| 82 | +this.updateCount(); |
| 83 | +this.hideForm(); |
| 84 | +}, 1); |
81 | 85 | });
|
82 | 86 |
|
83 | 87 | this.elem.addEventListener('page-comment-reply', ((event: CustomEvent<PageCommentReplyEventData>) => {
|
@@ -154,8 +158,10 @@ export class PageComments extends Component {
|
154 | 158 | protected resetForm(): void {
|
155 | 159 | this.removeEditor();
|
156 | 160 | this.formInput.value = '';
|
| 161 | +this.parentId = null; |
| 162 | +this.replyToRow.toggleAttribute('hidden', true); |
| 163 | +this.container.append(this.formContainer); |
157 | 164 | this.setContentReference('');
|
158 |
| -this.removeReplyTo(); |
159 | 165 | }
|
160 | 166 |
|
161 | 167 | protected showForm(): void {
|
@@ -165,9 +171,9 @@ export class PageComments extends Component {
|
165 | 171 | this.formContainer.scrollIntoView({behavior: 'smooth', block: 'nearest'});
|
166 | 172 | this.loadEditor();
|
167 | 173 |
|
168 |
| -// Ensure the active comments tab is displaying |
| 174 | +// Ensure the active comments tab is displaying if that's where we're showing the form |
169 | 175 | const tabs = window.$components.firstOnElement(this.elem, 'tabs');
|
170 |
| -if (tabs instanceof Tabs) { |
| 176 | +if (tabs instanceof Tabs && this.formContainer.closest('#comment-tab-panel-active')) { |
171 | 177 | tabs.show('comment-tab-panel-active');
|
172 | 178 | }
|
173 | 179 | }
|
@@ -176,7 +182,7 @@ export class PageComments extends Component {
|
176 | 182 | this.resetForm();
|
177 | 183 | this.formContainer.toggleAttribute('hidden', true);
|
178 | 184 | if (this.getActiveThreadCount() > 0) {
|
179 |
| -this.elem.append(this.addButtonContainer); |
| 185 | +this.activeContainer.append(this.addButtonContainer); |
180 | 186 | } else {
|
181 | 187 | this.commentCountBar.append(this.addButtonContainer);
|
182 | 188 | }
|
@@ -239,7 +245,8 @@ export class PageComments extends Component {
|
239 | 245 | }
|
240 | 246 |
|
241 | 247 | public startNewComment(contentReference: string): void {
|
242 |
| -this.removeReplyTo(); |
| 248 | +this.resetForm(); |
| 249 | +this.showForm(); |
243 | 250 | this.setContentReference(contentReference);
|
244 | 251 | }
|
245 | 252 |
|
|
0 commit comments