Skip to content

A platform for community discussion. Free, open, simple.

DEV: adds a caret option to widget dropdown (#9588)

Joffrey JAFFEUXa1b9150512cd
diff --git a/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js b/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js
index e882588d671..c063296e355 100644
--- a/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js
+++ b/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js
@@ -80,6 +80,9 @@ export const WidgetDropdownHeaderClass = {
<span class="label">
{{transformed.label}}
</span>
+ {{#if attrs.caret}}
+ {{d-icon "caret-down"}}
+ {{/if}}
`
};
@@ -218,6 +221,7 @@ export const WidgetDropdownClass = {
label=attrs.label
translatedLabel=attrs.translatedLabel
class=this.transformed.options.headerClass
+ caret=this.transformed.options.caret
)
}}
diff --git a/test/javascripts/widgets/widget-dropdown-test.js b/test/javascripts/widgets/widget-dropdown-test.js
index 46625d7d7b2..2bc7f94b267 100644
--- a/test/javascripts/widgets/widget-dropdown-test.js
+++ b/test/javascripts/widgets/widget-dropdown-test.js
@@ -302,3 +302,18 @@ widgetTest("bodyClass option", {
assert.ok(body().classList.contains("and-yet-small"));
}
});
+
+widgetTest("caret option", {
+ template: TEMPLATE,
+
+ beforeEach() {
+ this.setProperties(DEFAULT_CONTENT);
+ this.set("options", { caret: true });
+ },
+
+ test(assert) {
+ assert.ok(
+ exists("#my-dropdown .widget-dropdown-header .d-icon-caret-down")
+ );
+ }
+});