UX: Fix blank space for discourse-subscriptions plugin on user-main-nav (#36408)

The original discourse-subscriptions plugin uses a condition rendering
logic to make sure the button doesn't exist on other users' main page.

However, the logic doesn't consider the parent node `<li id="ember136"
class="user-main-nav-outlet billing ember-view">`. As a matter of fact,
there exists a blank that takes space and make the nav-bar misaligned.

This PR change the condition rendering logic `{{#if this.viewingSelf}}`
to the class `@classNameBindings("viewingSelf::hidden")`, so that the
whole element can hide entirely without leaving a blank space.

Before:
<img width="918" height="750" alt="image"
src="https://github.com/user-attachments/assets/79cf0886-a77c-467c-a00c-b06a3ae3a2eb"
/>

After:
<img width="982" height="837" alt="image"
src="https://github.com/user-attachments/assets/cea5139c-ffff-4a99-a1fb-b537ebc98c94"
/>
This commit is contained in:
small-lovely-cat
2025-12-03 11:30:45 +01:00
committed by GitHub
parent a8b312426b
commit 7e64696c64
@@ -2,12 +2,17 @@
import Component from "@ember/component";
import { LinkTo } from "@ember/routing";
import { service } from "@ember/service";
import { classNames, tagName } from "@ember-decorators/component";
import {
classNameBindings,
classNames,
tagName,
} from "@ember-decorators/component";
import icon from "discourse/helpers/d-icon";
import { i18n } from "discourse-i18n";
@tagName("li")
@classNames("user-main-nav-outlet", "billing")
@classNameBindings("viewingSelf::hidden")
export default class Billing extends Component {
@service currentUser;
@@ -20,11 +25,9 @@ export default class Billing extends Component {
}
<template>
{{#if this.viewingSelf}}
<LinkTo @route="user.billing">
{{icon "far-credit-card"}}
<span>{{i18n "discourse_subscriptions.navigation.billing"}}</span>
</LinkTo>
{{/if}}
<LinkTo @route="user.billing">
{{icon "far-credit-card"}}
<span>{{i18n "discourse_subscriptions.navigation.billing"}}</span>
</LinkTo>
</template>
}