FIX: class for section link when name has space (#20569)
Sidebar section link has class name based on link title. Title can contain spaces, therefore they should be replaced.
This commit is contained in:
parent
360d0dde65
commit
f2476d4b80
|
@ -28,7 +28,13 @@ export default class SectionLink extends Component {
|
||||||
let classNames = ["sidebar-section-link", "sidebar-row"];
|
let classNames = ["sidebar-section-link", "sidebar-row"];
|
||||||
|
|
||||||
if (this.args.linkName) {
|
if (this.args.linkName) {
|
||||||
classNames.push(`sidebar-section-link-${this.args.linkName}`);
|
classNames.push(
|
||||||
|
`sidebar-section-link-${this.args.linkName
|
||||||
|
.split(" ")
|
||||||
|
.filter((s) => s)
|
||||||
|
.join("-")
|
||||||
|
.toLowerCase()}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.args.class) {
|
if (this.args.class) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ module("Integration | Component | sidebar | section-link", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("default class attribute for link", async function (assert) {
|
test("default class attribute for link", async function (assert) {
|
||||||
const template = hbs`<Sidebar::SectionLink @linkName="test" @route="discovery.latest" />`;
|
const template = hbs`<Sidebar::SectionLink @linkName="Test Meta" @route="discovery.latest" />`;
|
||||||
|
|
||||||
await render(template);
|
await render(template);
|
||||||
|
|
||||||
|
@ -29,14 +29,14 @@ module("Integration | Component | sidebar | section-link", function (hooks) {
|
||||||
"ember-view",
|
"ember-view",
|
||||||
"sidebar-row",
|
"sidebar-row",
|
||||||
"sidebar-section-link",
|
"sidebar-section-link",
|
||||||
"sidebar-section-link-test",
|
"sidebar-section-link-test-meta",
|
||||||
],
|
],
|
||||||
"has the right class attribute for the link"
|
"has the right class attribute for the link"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("custom class attribute for link", async function (assert) {
|
test("custom class attribute for link", async function (assert) {
|
||||||
const template = hbs`<Sidebar::SectionLink @linkName="test" @route="discovery.latest" @class="123 abc" />`;
|
const template = hbs`<Sidebar::SectionLink @linkName="Test Meta" @route="discovery.latest" @class="123 abc" />`;
|
||||||
|
|
||||||
await render(template);
|
await render(template);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ module("Integration | Component | sidebar | section-link", function (hooks) {
|
||||||
"ember-view",
|
"ember-view",
|
||||||
"sidebar-row",
|
"sidebar-row",
|
||||||
"sidebar-section-link",
|
"sidebar-section-link",
|
||||||
"sidebar-section-link-test",
|
"sidebar-section-link-test-meta",
|
||||||
],
|
],
|
||||||
"has the right class attribute for the link"
|
"has the right class attribute for the link"
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue