Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/short-windows-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stackoverflow/stacks-editor": patch
---

Minor a11y and layout fixes for "Run code snippets" button
5 changes: 2 additions & 3 deletions plugins/official/stack-snippets/src/snippet-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ export class StackSnippetView implements NodeView {
if (opts && opts.renderer) {
const runCodeButton = document.createElement("button");
runCodeButton.type = "button";
runCodeButton.className = "s-btn s-btn__filled";
runCodeButton.title = "Run code snippet";
runCodeButton.setAttribute("aria-label", "Run code snippet");
runCodeButton.className =
"s-btn s-btn__filled d-inline-flex ai-center g2";
// create the svg svg-icon-bg element
const runIcon = document.createElement("span");
runIcon.className = "svg-icon-bg iconPlay";
Expand Down
7 changes: 1 addition & 6 deletions plugins/official/stack-snippets/test/render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@
const shouldHaveRunCodeButton = (rendered: Element) => {
const runCode = rendered.querySelectorAll("div.snippet-ctas > button");
expect(runCode).toHaveLength(1);
expect(runCode[0].attributes.getNamedItem("title").value).toBe(
"Run code snippet"
);
expect(runCode[0].attributes.getNamedItem("aria-label").value).toBe(
"Run code snippet"
);
expect(runCode[0].textContent).toBe("Run code snippet");
};

const shouldHaveLanguageBlocks = (rendered: Element, langs: string[]) => {
Expand All @@ -50,7 +45,7 @@
expect(codeBlocks).toHaveLength(langs.length);
};

it.each(validSnippetRenderCases)(

Check warning on line 48 in plugins/official/stack-snippets/test/render.test.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
"should render snippets",
(markdown: string, langs: string[]) => {
const richEditorView = richView(markdown, {
Expand All @@ -65,7 +60,7 @@
}
);

it.each(validSnippetRenderCases)(

Check warning on line 63 in plugins/official/stack-snippets/test/render.test.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
"should render without button if no render supplied",
(markdown: string, langs: string[]) => {
const richEditorView = richView(markdown);
Expand Down
5 changes: 1 addition & 4 deletions plugins/official/stack-snippets/test/snippet-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ describe("StackSnippetView", () => {
);

expect(runCodeButton).toHaveLength(1);
expect(runCodeButton[0].getAttribute("aria-label")).toBe(
"Run code snippet"
);
expect(runCodeButton[0].getAttribute("title")).toBe("Run code snippet");
expect(runCodeButton[0].textContent).toBe("Run code snippet");
});

it("should not render run code button if no renderer provided", () => {
Expand Down