A platform for community discussion. Free, open, simple.
FIX: replace dropdown with button when there's only one option (#30242)
Régis Hanol1791abab2548
diff --git a/app/assets/javascripts/discourse/app/components/topic-footer-buttons.hbs b/app/assets/javascripts/discourse/app/components/topic-footer-buttons.hbsindex fa8fe109f89..c1c93589ffd 100644--- a/app/assets/javascripts/discourse/app/components/topic-footer-buttons.hbs+++ b/app/assets/javascripts/discourse/app/components/topic-footer-buttons.hbs@@ -59,7 +59,22 @@{{/each}}{{#if this.site.mobileView}}- {{#if this.dropdownButtons}}+ {{#if this.loneDropdownButton}}+ <DButton+ @action={{this.loneDropdownButton.action}}+ @icon={{this.loneDropdownButton.icon}}+ @translatedLabel={{this.loneDropdownButton.label}}+ @translatedTitle={{this.loneDropdownButton.title}}+ @translatedAriaLabel={{this.loneDropdownButton.ariaLabel}}+ @disabled={{this.loneDropdownButton.disabled}}+ id={{concat "topic-footer-button-" this.loneDropdownButton.id}}+ class={{concat-class+ "btn-default"+ "topic-footer-button"+ this.loneDropdownButton.classNames+ }}+ />+ {{else if (gt this.dropdownButtons.length 1)}}<DMenu@modalForMobile={{true}}@identifier="topic-footer-mobile-dropdown"diff --git a/app/assets/javascripts/discourse/app/components/topic-footer-buttons.js b/app/assets/javascripts/discourse/app/components/topic-footer-buttons.jsindex 215bebf364a..8ccd589730d 100644--- a/app/assets/javascripts/discourse/app/components/topic-footer-buttons.js+++ b/app/assets/javascripts/discourse/app/components/topic-footer-buttons.js@@ -48,6 +48,11 @@ export default class TopicFooterButtons extends Component {return inlineButtons.filter((button) => button.dropdown);}+ @discourseComputed("dropdownButtons.[]")+ loneDropdownButton(dropdownButtons) {+ return dropdownButtons.length === 1 ? dropdownButtons[0] : null;+ }+@discourseComputed("topic.isPrivateMessage")showNotificationsButton(isPM) {return !isPM || this.canSendPms;