Skip to content

Commit a99b5ab

Browse files
authored
fix: rollback comments colors / ui (#2216)
1 parent ba03e76 commit a99b5ab

5 files changed

Lines changed: 54 additions & 31 deletions

File tree

packages/superdoc/src/assets/styles/tokens.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@
6969
--sd-action-primary-hover: var(--sd-color-blue-600);
7070

7171
/* ─── Component: Comment Dialog ─── */
72-
--sd-comment-bg: var(--sd-color-gray-100);
73-
--sd-comment-bg-hover: var(--sd-surface-hover);
72+
--sd-comment-bg: #f3f6fd;
73+
--sd-comment-bg-hover: #f3f6fd;
7474
--sd-comment-bg-active: var(--sd-surface-card);
7575
--sd-comment-bg-resolved: #f0f0f0;
7676
--sd-comment-border-active: var(--sd-border-subtle);
7777
--sd-comment-radius: var(--sd-radius-lg);
7878
--sd-comment-padding: 16px;
79-
--sd-comment-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
79+
--sd-comment-shadow: 0px 4px 12px 0px rgba(50, 50, 50, 0.15);
8080
--sd-comment-max-width: 300px;
8181
--sd-comment-min-width: 200px;
8282
--sd-comment-separator: var(--sd-border-subtle);

packages/superdoc/src/components/CommentsLayer/CommentDialog.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,13 @@ describe('CommentDialog.vue', () => {
624624
commentsStoreStub.activeComment.value = 'tc-parent';
625625
await nextTick();
626626

627+
// Expand the collapsed thread (>= 2 children triggers collapse)
628+
const collapsedPill = wrapper.find('.collapsed-replies');
629+
if (collapsedPill.exists()) {
630+
await collapsedPill.trigger('click');
631+
await nextTick();
632+
}
633+
627634
const headers = wrapper.findAllComponents(CommentHeaderStub);
628635
expect(headers).toHaveLength(3);
629636

@@ -696,6 +703,13 @@ describe('CommentDialog.vue', () => {
696703
commentsStoreStub.activeComment.value = 'tc-parent';
697704
await nextTick();
698705

706+
// Expand the collapsed thread (>= 2 children triggers collapse)
707+
const collapsedPill = wrapper.find('.collapsed-replies');
708+
if (collapsedPill.exists()) {
709+
await collapsedPill.trigger('click');
710+
await nextTick();
711+
}
712+
699713
const headers = wrapper.findAllComponents(CommentHeaderStub);
700714
expect(headers).toHaveLength(3);
701715
expect(headers[0].props('comment').commentId).toBe('tc-parent');

packages/superdoc/src/components/CommentsLayer/CommentDialog.vue

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ watch(isActiveComment, (active) => {
207207
}
208208
});
209209
210-
/* ── Step 3: Thread collapse (Google Docs pattern) ──
211-
* >=3 replies → collapse: parent + first reply + "N more replies" + last reply
212-
* <3 replies → show all
210+
/* ── Step 3: Thread collapse ──
211+
* >=2 replies → collapse: parent + "N more replies" + last reply
212+
* <2 replies → show all
213213
* Clicking "N more replies" or the card → expand all + activate
214214
* Deactivating → re-collapse
215215
*/
@@ -218,27 +218,26 @@ const childComments = computed(() => comments.value.slice(1));
218218
219219
const shouldCollapseThread = computed(() => {
220220
if (threadExpanded.value) return false;
221-
return childComments.value.length >= 3;
221+
return childComments.value.length >= 2;
222222
});
223223
224224
const visibleComments = computed(() => {
225225
if (!shouldCollapseThread.value) return comments.value;
226-
// Collapsed: parent + first reply + last reply
226+
// Collapsed: parent + last reply
227227
const parent = comments.value[0];
228-
const first = childComments.value[0];
229228
const last = childComments.value[childComments.value.length - 1];
230-
return [parent, first, last].filter(Boolean);
229+
return [parent, last].filter(Boolean);
231230
});
232231
233232
const collapsedReplyCount = computed(() => {
234233
if (!shouldCollapseThread.value) return 0;
235-
return childComments.value.length - 2; // first + last are shown
234+
return childComments.value.length - 1; // only last is shown
236235
});
237236
238237
const collapsedReplyAuthors = computed(() => {
239238
if (!shouldCollapseThread.value) return [];
240-
// Hidden = middle replies (first + last are visible)
241-
const hidden = childComments.value.slice(1, -1);
239+
// Hidden = all replies except last
240+
const hidden = childComments.value.slice(0, -1);
242241
const seen = new Set();
243242
return hidden
244243
.map((c) =>
@@ -543,9 +542,9 @@ watch(editingCommentId, (commentId) => {
543542
/>
544543
</div>
545544
<div class="reply-actions">
546-
<button class="reply-btn-cancel" @click.stop.prevent="handleCancel">Cancel</button>
545+
<button class="sd-button reply-btn-cancel" @click.stop.prevent="handleCancel">Cancel</button>
547546
<button
548-
class="reply-btn-primary"
547+
class="sd-button primary reply-btn-primary"
549548
@click.stop.prevent="handleAddComment"
550549
:disabled="!hasTextContent"
551550
:class="{ 'is-disabled': !hasTextContent }"
@@ -669,8 +668,8 @@ watch(editingCommentId, (commentId) => {
669668
</div>
670669
</div>
671670
672-
<!-- Thread collapse: after first reply (index 1), show "N more replies" -->
673-
<template v-if="shouldCollapseThread && index === 1">
671+
<!-- Thread collapse: after parent (index 0), show "N more replies" -->
672+
<template v-if="shouldCollapseThread && index === 0">
674673
<div class="comment-separator"></div>
675674
<div class="collapsed-replies" @click.stop.prevent="expandThread">
676675
<div class="collapsed-avatars">
@@ -702,9 +701,9 @@ watch(editingCommentId, (commentId) => {
702701
/>
703702
</div>
704703
<div class="reply-actions">
705-
<button class="reply-btn-cancel" @click.stop.prevent="handleCancel">Cancel</button>
704+
<button class="sd-button reply-btn-cancel" @click.stop.prevent="handleCancel">Cancel</button>
706705
<button
707-
class="reply-btn-primary"
706+
class="sd-button primary reply-btn-primary"
708707
@click.stop.prevent="handleAddComment"
709708
:disabled="!hasTextContent"
710709
:class="{ 'is-disabled': !hasTextContent }"
@@ -724,7 +723,7 @@ watch(editingCommentId, (commentId) => {
724723
flex-direction: column;
725724
padding: var(--sd-comment-padding, 16px);
726725
border-radius: var(--sd-comment-radius, 12px);
727-
background-color: var(--sd-comment-bg, #f5f5f5);
726+
background-color: var(--sd-comment-bg, #f3f6fd);
728727
border: 1px solid transparent;
729728
font-family: var(--sd-ui-font-family, Arial, Helvetica, sans-serif);
730729
font-size: var(--sd-comment-body-size, 14px);
@@ -740,7 +739,7 @@ watch(editingCommentId, (commentId) => {
740739
cursor: pointer;
741740
}
742741
.comments-dialog:not(.is-active):not(.is-resolved):hover {
743-
background-color: var(--sd-comment-bg-hover, #f2f2f2);
742+
background-color: var(--sd-comment-bg-hover, #f3f6fd);
744743
}
745744
.comments-dialog:not(.is-resolved):hover :deep(.overflow-menu) {
746745
opacity: 1;
@@ -749,7 +748,7 @@ watch(editingCommentId, (commentId) => {
749748
.comments-dialog.is-active {
750749
background-color: var(--sd-comment-bg-active, #ffffff);
751750
border-color: var(--sd-comment-border-active, #e0e0e0);
752-
box-shadow: var(--sd-comment-shadow, 0 4px 20px rgba(15, 23, 42, 0.08));
751+
box-shadow: var(--sd-comment-shadow, 0px 4px 12px 0px rgba(50, 50, 50, 0.15));
753752
z-index: 10;
754753
}
755754
.comments-dialog.is-resolved {
@@ -967,7 +966,7 @@ watch(editingCommentId, (commentId) => {
967966
transition: background 150ms;
968967
}
969968
.reply-btn-primary:hover {
970-
background: var(--sd-color-blue-600, #0f44cc);
969+
background: var(--sd-action-primary-hover, #0f44cc);
971970
}
972971
.reply-btn-primary.is-disabled {
973972
background: var(--sd-color-gray-400, #dbdbdb);
@@ -986,7 +985,7 @@ watch(editingCommentId, (commentId) => {
986985
justify-content: flex-end;
987986
width: 100%;
988987
}
989-
.sd-button {
988+
.comment-footer .sd-button {
990989
font-size: 12px;
991990
margin-left: 5px;
992991
}

packages/superdoc/src/components/general/Avatar.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ const getInitials = (name, email) => {
3535
<style scoped>
3636
.user-container {
3737
border-radius: 50%;
38+
border: var(--sd-comment-avatar-border, 2px solid #333);
3839
font-size: var(--sd-comment-avatar-font-size, 11px);
3940
font-weight: 600;
40-
color: var(--sd-comment-avatar-color, #1355ff);
41-
background-color: var(--sd-comment-avatar-bg, #ebf0ff);
41+
color: var(--sd-comment-avatar-color, #fff);
42+
background-color: var(--sd-comment-avatar-bg, #00000098);
4243
4344
width: var(--sd-comment-avatar-size, 28px);
4445
height: var(--sd-comment-avatar-size, 28px);

tests/behavior/tests/comments/comment-thread-collapse.spec.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test.fixme(
1111
'v-click-outside races with programmatic activation on WebKit',
1212
);
1313

14-
test('thread with 3+ replies collapses and expands on click', async ({ superdoc }) => {
14+
test('thread with 2+ replies collapses and expands on click', async ({ superdoc }) => {
1515
await assertDocumentApiReady(superdoc.page);
1616

1717
// Type text and add a comment through the UI
@@ -23,7 +23,7 @@ test('thread with 3+ replies collapses and expands on click', async ({ superdoc
2323
commentText: 'parent comment',
2424
});
2525

26-
// Add 4 replies to trigger collapse (threshold is childComments.length >= 3)
26+
// Add 4 replies to trigger collapse (threshold is childComments.length >= 2)
2727
await replyToComment(superdoc.page, { parentCommentId: commentId, text: 'reply one' });
2828
await replyToComment(superdoc.page, { parentCommentId: commentId, text: 'reply two' });
2929
await replyToComment(superdoc.page, { parentCommentId: commentId, text: 'reply three' });
@@ -33,16 +33,25 @@ test('thread with 3+ replies collapses and expands on click', async ({ superdoc
3333
// Re-assert highlight exists — replies trigger re-renders that may temporarily remove highlights
3434
await superdoc.assertCommentHighlightExists({ text: 'collapse', timeoutMs: 10_000 });
3535

36+
// Deactivate first so the dialog renders in collapsed state, then re-activate.
37+
// On Firefox, replyToComment shifts activeComment to a child ID which can leave
38+
// the thread in an expanded state.
39+
await superdoc.page.evaluate(() => {
40+
const sd = (window as any).superdoc;
41+
sd.commentsStore.$patch({ activeComment: null });
42+
});
43+
await superdoc.waitForStable();
44+
3645
// Activate the comment dialog
3746
const dialog = await activateCommentDialog(superdoc, 'collapse');
3847

3948
// The collapsed-replies pill should be visible with "more replies" text
4049
const collapsedPill = dialog.locator('.collapsed-replies');
41-
await expect(collapsedPill).toBeVisible({ timeout: 5_000 });
50+
await expect(collapsedPill).toBeVisible({ timeout: 10_000 });
4251
await expect(collapsedPill).toContainText('more replies');
4352

44-
// In collapsed state: parent + first reply + last reply = 3 visible conversation items
45-
await expect(dialog.locator('.conversation-item')).toHaveCount(3);
53+
// In collapsed state: parent + last reply = 2 visible conversation items
54+
await expect(dialog.locator('.conversation-item')).toHaveCount(2);
4655

4756
// Click the collapsed pill to expand all replies
4857
await collapsedPill.click();

0 commit comments

Comments
 (0)