A11Y: makes post-edits-indicator a button instead of a link (#11811)
This commit is contained in:
parent
dc268822a4
commit
6f13d2b039
|
@ -62,6 +62,15 @@ export const ButtonClass = {
|
||||||
h("span.d-button-label", I18n.t(attrs.label, attrs.labelOptions))
|
h("span.d-button-label", I18n.t(attrs.label, attrs.labelOptions))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (attrs.translatedLabel) {
|
||||||
|
contents.push(
|
||||||
|
h(
|
||||||
|
"span.d-button-label",
|
||||||
|
attrs.translatedLabel.toString(),
|
||||||
|
attrs.translatedLabelOptions
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
if (attrs.contents) {
|
if (attrs.contents) {
|
||||||
contents.push(attrs.contents);
|
contents.push(attrs.contents);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { createWidget } from "discourse/widgets/widget";
|
import { createWidget } from "discourse/widgets/widget";
|
||||||
import { h } from "virtual-dom";
|
|
||||||
import { iconNode } from "discourse-common/lib/icon-library";
|
|
||||||
import { longDate } from "discourse/lib/formatter";
|
import { longDate } from "discourse/lib/formatter";
|
||||||
|
|
||||||
function mult(val) {
|
function mult(val) {
|
||||||
|
@ -53,24 +51,16 @@ export default createWidget("post-edits-indicator", {
|
||||||
title = `${I18n.t("post.last_edited_on")} ${date}`;
|
title = `${I18n.t("post.last_edited_on")} ${date}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const contents = [
|
return this.attach("flat-button", {
|
||||||
attrs.version > 1 ? attrs.version - 1 : "",
|
icon,
|
||||||
" ",
|
title,
|
||||||
iconNode(icon),
|
className,
|
||||||
];
|
action: "onPostEditsIndicatorClick",
|
||||||
|
translatedLabel: attrs.version > 1 ? attrs.version - 1 : "",
|
||||||
return h(
|
});
|
||||||
"a",
|
|
||||||
{
|
|
||||||
className,
|
|
||||||
attributes: { title, href: "#" },
|
|
||||||
},
|
|
||||||
contents
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
click(e) {
|
onPostEditsIndicatorClick() {
|
||||||
e.preventDefault();
|
|
||||||
if (this.attrs.wiki && this.attrs.version === 1) {
|
if (this.attrs.wiki && this.attrs.version === 1) {
|
||||||
this.sendWidgetAction("editPost");
|
this.sendWidgetAction("editPost");
|
||||||
} else if (this.attrs.canViewEditHistory) {
|
} else if (this.attrs.canViewEditHistory) {
|
||||||
|
|
|
@ -146,7 +146,7 @@ acceptance("Topic", function (needs) {
|
||||||
await click(".topic-post:nth-of-type(1) button.show-post-admin-menu");
|
await click(".topic-post:nth-of-type(1) button.show-post-admin-menu");
|
||||||
await click(".btn.wiki");
|
await click(".btn.wiki");
|
||||||
|
|
||||||
assert.ok(queryAll("a.wiki").length === 1, "it shows the wiki icon");
|
assert.ok(queryAll("button.wiki").length === 1, "it shows the wiki icon");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Visit topic routes", async function (assert) {
|
test("Visit topic routes", async function (assert) {
|
||||||
|
|
|
@ -378,6 +378,10 @@ export function queryAll() {
|
||||||
return window.find(...arguments);
|
return window.find(...arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function query() {
|
||||||
|
return document.querySelector(...arguments);
|
||||||
|
}
|
||||||
|
|
||||||
export function invisible(selector) {
|
export function invisible(selector) {
|
||||||
const $items = queryAll(selector + ":visible");
|
const $items = queryAll(selector + ":visible");
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -3,6 +3,7 @@ import componentTest, {
|
||||||
} from "discourse/tests/helpers/component-test";
|
} from "discourse/tests/helpers/component-test";
|
||||||
import {
|
import {
|
||||||
discourseModule,
|
discourseModule,
|
||||||
|
query,
|
||||||
queryAll,
|
queryAll,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
|
@ -69,4 +70,16 @@ discourseModule("Integration | Component | Widget | button", function (hooks) {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
componentTest("translatedLabel", {
|
||||||
|
template: '{{mount-widget widget="button" args=args}}',
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
this.set("args", { translatedLabel: "foo bar" });
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert) {
|
||||||
|
assert.equal(query("button span.d-button-label").innerText, "foo bar");
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -113,7 +113,7 @@ discourseModule("Integration | Component | Widget | post", function (hooks) {
|
||||||
this.on("showHistory", () => (this.historyShown = true));
|
this.on("showHistory", () => (this.historyShown = true));
|
||||||
},
|
},
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
await click(".post-info.edits");
|
await click(".post-info.edits button");
|
||||||
assert.ok(this.historyShown, "clicking the pencil shows the history");
|
assert.ok(this.historyShown, "clicking the pencil shows the history");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -295,15 +295,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.heatmap-high,
|
.heatmap-high,
|
||||||
.heatmap-high a {
|
.heatmap-high a,
|
||||||
|
.heatmap-high .d-icon,
|
||||||
|
.heatmap-high .d-button-label {
|
||||||
color: #fe7a15 !important;
|
color: #fe7a15 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.heatmap-med,
|
.heatmap-med,
|
||||||
.heatmap-med a {
|
.heatmap-med a,
|
||||||
|
.heatmap-med .d-icon,
|
||||||
|
.heatmap-med .d-button-label {
|
||||||
color: #cf7721 !important;
|
color: #cf7721 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.heatmap-low,
|
.heatmap-low,
|
||||||
.heatmap-low a {
|
.heatmap-low a,
|
||||||
|
.heatmap-low .d-icon,
|
||||||
|
.heatmap-low .d-button-label {
|
||||||
color: #9b764f !important;
|
color: #9b764f !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -655,6 +655,21 @@ blockquote {
|
||||||
&.raw-email {
|
&.raw-email {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
&.edits {
|
||||||
|
.widget-button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.d-button-label {
|
||||||
|
order: 0;
|
||||||
|
padding-right: 0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.d-icon {
|
||||||
|
order: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
|
|
Loading…
Reference in New Issue