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:
Krzysztof Kotlarek 2023-03-08 12:07:03 +11:00 committed by GitHub
parent 360d0dde65
commit f2476d4b80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -28,7 +28,13 @@ export default class SectionLink extends Component {
let classNames = ["sidebar-section-link", "sidebar-row"];
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) {

View File

@ -18,7 +18,7 @@ module("Integration | Component | sidebar | section-link", function (hooks) {
setupRenderingTest(hooks);
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);
@ -29,14 +29,14 @@ module("Integration | Component | sidebar | section-link", function (hooks) {
"ember-view",
"sidebar-row",
"sidebar-section-link",
"sidebar-section-link-test",
"sidebar-section-link-test-meta",
],
"has the right class attribute for the link"
);
});
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);
@ -49,7 +49,7 @@ module("Integration | Component | sidebar | section-link", function (hooks) {
"ember-view",
"sidebar-row",
"sidebar-section-link",
"sidebar-section-link-test",
"sidebar-section-link-test-meta",
],
"has the right class attribute for the link"
);