Skip to content

Commit

Permalink
Make sure the aria-live element is hidden when printing
Browse files Browse the repository at this point in the history
FIX: Fix an issue where, on some browsers, the screenreader announced text ended up
in the printed document.

Closes codemirror/dev#1298
  • Loading branch information
marijnh committed Nov 15, 2023
1 parent cf5e5a9 commit 9c2be65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/editorview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class EditorView {
this.scrollDOM.appendChild(this.contentDOM)

this.announceDOM = document.createElement("div")
this.announceDOM.style.cssText = "position: fixed; top: -10000px"
this.announceDOM.className = "cm-announced"
this.announceDOM.setAttribute("aria-live", "polite")

this.dom = document.createElement("div")
Expand Down
8 changes: 8 additions & 0 deletions src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ export const baseTheme = buildTheme("." + baseThemeID, {
display: "block"
},

".cm-announced": {
position: "fixed",
top: "-10000px"
},
"@media print": {
".cm-announced": { display: "none" }
},

"&light .cm-activeLine": { backgroundColor: "#cceeff44" },
"&dark .cm-activeLine": { backgroundColor: "#99eeff33" },

Expand Down

0 comments on commit 9c2be65

Please sign in to comment.