A platform for community discussion. Free, open, simple.
UX: Nested replies sticky avatars for posts (#41125)
Mark VanLandinghamb84fdf355c7d
diff --git a/app/assets/stylesheets/common/nested-view.scss b/app/assets/stylesheets/common/nested-view.scssindex bee31f06f91..766b5ba062d 100644--- a/app/assets/stylesheets/common/nested-view.scss+++ b/app/assets/stylesheets/common/nested-view.scss@@ -8,6 +8,7 @@// ── Top-level nested view ──────────────────────────────────────────.nested-view {+ --nested-sticky-avatar-bottom-offset: calc(var(--space-2) + var(--space-1));background: var(--secondary);margin: 0 auto;padding: var(--space-4);@@ -418,9 +419,14 @@--nested-line-width: 1px;--nested-line-center-adjust: 0.5px;--nested-load-more-left-adjust: var(--nested-line-width);+ --nested-sticky-avatar-top: calc(+ var(--header-offset, 0px) + var(--nested-avatar-size) + var(--space-2) ++ var(--space-2)+ );- // Grid splits article (row 1) from children (row 2) so the gutter's- // depth-line naturally stops at the article bottom.+ // Grid splits article (row 1) from children (row 2) so the sticky avatar is+ // bounded by the post itself and does not continue past the post menu into+ // the reply subtree.display: grid;grid-template-columns: var(--nested-avatar-size) 1fr;column-gap: var(--nested-column-gap);@@ -508,16 +514,19 @@}}- // Left column: avatar on top, clickable depth line below.- // Grid row 1 only — does not extend into the children row.+ // Left column: sticky avatar on top, clickable depth line below.&__gutter {grid-column: 1;grid-row: 1;+ margin-bottom: var(--nested-sticky-avatar-bottom-offset);display: flex;flex-direction: column;align-items: center;.topic-avatar {+ position: sticky;+ top: var(--nested-sticky-avatar-top);+ z-index: 2;border-top: none;float: none;width: auto;@@ -851,26 +860,6 @@color: var(--primary-low-mid);}- &__collapsed-avatar {- display: flex;- flex: 0 0 var(--nested-avatar-size);- align-items: center;- justify-content: center;- width: var(--nested-avatar-size);- height: var(--nested-avatar-size);- color: var(--primary-low-mid);-- .avatar {- width: var(--nested-avatar-size);- height: var(--nested-avatar-size);- }-- .d-icon {- width: 14px;- height: 14px;- }- }-&__collapsed-username {color: var(--primary-high-or-secondary-low);}@@ -938,6 +927,9 @@}&__placeholder-avatar {+ position: sticky;+ top: var(--nested-sticky-avatar-top);+ z-index: 2;width: var(--nested-avatar-size);height: var(--nested-avatar-size);display: flex;@@ -1294,35 +1286,34 @@}// ── Individual nested post overrides ──- // Gutter becomes a compact rail column. The post article spans the rail and- // content columns because mobile renders the avatar inline in the header,- // while children remain indented in the content column.+ // Gutter stays wide enough for the avatar so sticky avatars remain attached+ // to the mobile rail, while children remain indented in the content column..nested-post {- --nested-line-gutter: 14px;+ --nested-line-gutter: var(--nested-avatar-size);--nested-column-gap: var(--space-1);--nested-mobile-line-offset: calc(var(--nested-line-gutter) / 2);+ --nested-line-center-adjust: var(--nested-line-width);+ --nested-mobile-line-nudge: calc(-1 * var(--space-1));--nested-mobile-line-start: calc(var(--nested-avatar-size) + 6px);- --nested-mobile-content-indent: calc(- var(--nested-avatar-size) + var(--space-1)- );grid-template-columns: var(--nested-line-gutter) 1fr;-- // Explicit rows are required so grid-row: 1 / -1 on the gutter- // can resolve -1 to the end of the explicit grid (line 3).- // Without this, -1 falls back to line 1 and the gutter only spans row 1.- grid-template-rows: auto 1fr;column-gap: var(--nested-column-gap);// Tighter vertical spacing between siblings--nested-vertical-gap: 0.25em;- // Gutter spans all grid rows so the depth-line runs continuously- // through the article and children areas.+ // Keep the gutter bounded to the post row on mobile too. The depth-line+ // remains available as the collapse target for this post, but the sticky+ // avatar stops with the post instead of following the entire child subtree.> .nested-post__gutter {- grid-row: 1 / -1;+ grid-row: 1;position: relative;z-index: 1;pointer-events: none;++ .topic-avatar,+ .nested-post__placeholder-avatar {+ pointer-events: auto;+ }}// Depth-line: vertical bar under the avatar, no decorative hooks.@@ -1330,7 +1321,7 @@position: absolute;top: var(--nested-mobile-line-start);bottom: 0;- left: 0;+ left: var(--nested-mobile-line-nudge);min-height: 0;pointer-events: auto;@@ -1360,21 +1351,6 @@display: none;}- // Inline avatar in the post header (rendered via template)- .nested-post__header .topic-avatar {- align-self: flex-start;- border-top: none;- float: none;- width: auto;- padding-top: 0;- height: auto;- }-- .nested-post__article,- .nested-post__collapsed-bar {- grid-column: 1 / -1;- }-.nested-post__collapsed-bar {padding-inline: 0;}@@ -1419,17 +1395,6 @@}}- .nested-post__content,- .nested-post__menu,- .nested-post__controls,- .post-links-container {- margin-left: var(--nested-mobile-content-indent);- }-- .nested-post__expand-replies {- margin-left: var(--nested-mobile-content-indent);- }-.nested-post__content {overflow-x: auto;}diff --git a/frontend/discourse/app/components/nested/post.gjs b/frontend/discourse/app/components/nested/post.gjsindex 5caef1626f3..956502c278b 100644--- a/frontend/discourse/app/components/nested/post.gjs+++ b/frontend/discourse/app/components/nested/post.gjs@@ -25,7 +25,6 @@ import { nativeShare } from "discourse/lib/pwa-utils";import { clipboardCopy } from "discourse/lib/utilities";import { and, not, or } from "discourse/truth-helpers";import DButton from "discourse/ui-kit/d-button";-import dAvatar from "discourse/ui-kit/helpers/d-avatar";import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";import dIcon from "discourse/ui-kit/helpers/d-icon";import { i18n } from "discourse-i18n";@@ -607,30 +606,28 @@ export default class NestedPost extends Component {></button>{{/if}}<div class="nested-post__gutter">- {{#unless this.isMobile}}- {{#if this.isDeletedPlaceholder}}- <div class="nested-post__placeholder-avatar">- {{dIcon "trash-can"}}- </div>- {{else if this.renderIgnoredPlaceholder}}- <button- type="button"- class="nested-post__placeholder-avatar nested-post__placeholder-avatar--reveal"- data-post-number={{@post.post_number}}- aria-label={{i18n "nested_replies.toggle_ignored_content"}}- disabled={{this.loadingIgnoredContent}}- {{on "click" this.revealIgnoredContent}}- >- {{#if this.loadingIgnoredContent}}- {{dIcon "spinner" class="fa-spin"}}- {{else}}- {{dIcon "far-eye-slash"}}- {{/if}}- </button>- {{else}}- <PostAvatar @post={{@post}} @size="small" />- {{/if}}- {{/unless}}+ {{#if this.isDeletedPlaceholder}}+ <div class="nested-post__placeholder-avatar">+ {{dIcon "trash-can"}}+ </div>+ {{else if this.renderIgnoredPlaceholder}}+ <button+ type="button"+ class="nested-post__placeholder-avatar nested-post__placeholder-avatar--reveal"+ data-post-number={{@post.post_number}}+ aria-label={{i18n "nested_replies.toggle_ignored_content"}}+ disabled={{this.loadingIgnoredContent}}+ {{on "click" this.revealIgnoredContent}}+ >+ {{#if this.loadingIgnoredContent}}+ {{dIcon "spinner" class="fa-spin"}}+ {{else}}+ {{dIcon "far-eye-slash"}}+ {{/if}}+ </button>+ {{else}}+ <PostAvatar @post={{@post}} @size="small" />+ {{/if}}{{#if (and this.showDepthLine (not this.effectiveCollapsed))}}<buttontype="button"@@ -663,18 +660,6 @@ export default class NestedPost extends Component {data-post-number={{@post.post_number}}{{on "click" this.toggleExpanded}}>- {{#if this.isMobile}}- <span class="nested-post__collapsed-avatar" aria-hidden="true">- {{#if this.isDeletedPlaceholder}}- {{dIcon "trash-can"}}- {{else if this.renderIgnoredPlaceholder}}- {{dIcon "far-eye-slash"}}- {{else}}- {{! PostAvatar renders a user link; keep this avatar non-interactive inside the collapsed button. }}- {{dAvatar @post imageSize="small" hideTitle=true}}- {{/if}}- </span>- {{/if}}{{dIcon "discourse-circle-plus"}}{{#if this.isDeletedPlaceholder}}<span class="nested-post__collapsed-username">{{i18n@@ -765,9 +750,6 @@ export default class NestedPost extends Component {@outletArgs={{postOutletArgs}}><div class="nested-post__header">- {{#if this.isMobile}}- <PostAvatar @post={{@post}} @size="small" />- {{/if}}<PluginOutlet@name="post-metadata"@outletArgs={{postOutletArgs}}diff --git a/frontend/discourse/tests/integration/components/nested/post-test.gjs b/frontend/discourse/tests/integration/components/nested/post-test.gjsindex 06e5167adf4..fb3c471fcf3 100644--- a/frontend/discourse/tests/integration/components/nested/post-test.gjs+++ b/frontend/discourse/tests/integration/components/nested/post-test.gjs@@ -161,7 +161,7 @@ module("Integration | Component | Nested | Post", function (hooks) {);});- test("mobile collapsed posts keep an avatar in the collapsed bar", async function (assert) {+ test("mobile collapsed posts keep an avatar in the gutter", async function (assert) {const site = getOwner(this).lookup("service:site");sinon.stub(site, "mobileView").value(true);@@ -170,8 +170,11 @@ module("Integration | Component | Nested | Post", function (hooks) {assert.dom(".nested-post__article").doesNotExist("collapses the post body");assert- .dom(".nested-post__collapsed-avatar .avatar")- .exists("renders the post avatar in the mobile collapsed bar");+ .dom(".nested-post__gutter .topic-avatar")+ .exists("renders the post avatar area in the mobile gutter");+ assert+ .dom(".nested-post__collapsed-avatar")+ .doesNotExist("does not duplicate the avatar in the collapsed bar");});test("post registration can update post topic", async function (assert) {