Skip to content

Commit

Permalink
fix codemirror hidden images (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
loiswells97 authored Mar 2, 2023
1 parent 2a0e2f5 commit 2c91cf6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Renaming project, adding new file or renaming file always triggers autosave (#368)
- Use `HtmlRunner` for `html` projects (#378)
- Accessibility Fixes (#373, #382, #383)
- Add `visibility: hidden` to the codemirror `cm-widgetBuffer` (#384)
- Hide the codemirror `cm-widgetBuffer` (#384, #395)
- Height discrepancy of the tab containers (#385)

## [0.12.0] - 2023-01-27
Expand Down
3 changes: 1 addition & 2 deletions src/components/Editor/EditorPanel/EditorPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ const EditorPanel = ({
// Add alt text to hidden images to fix accessibility error
const hiddenImages = view.contentDOM.getElementsByClassName('cm-widgetBuffer');
for (let img of hiddenImages) {
img.setAttribute('alt', null)
img.style.visibility = 'hidden'
img.setAttribute('role', 'presentation')
}

return () => {
Expand Down
14 changes: 11 additions & 3 deletions src/components/Editor/EditorPanel/EditorPanel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import configureStore from 'redux-mock-store'
import { Provider } from "react-redux"
import { SettingsContext } from "../../../settings"
import { render } from '@testing-library/react'
import { axe, toHaveNoViolations }from 'jest-axe'
import EditorPanel from './EditorPanel'

expect.extend(toHaveNoViolations)

describe('When font size is set', () => {

let editorContainer
let editor

beforeEach(() => {
const middlewares = []
Expand All @@ -21,17 +24,22 @@ describe('When font size is set', () => {
}
}
const store = mockStore(initialState);
editorContainer = render(
const editorContainer = render(
<Provider store={store}>
<SettingsContext.Provider value={{ theme: 'dark', fontSize: 'myFontSize' }}>
<EditorPanel fileName='main' extension='py'/>
</SettingsContext.Provider>
</Provider>
)
editor = editorContainer.container.querySelector('.editor')
})

test('Font size class is set correctly', () => {
const editor = editorContainer.container.querySelector('.editor')
expect(editor).toHaveClass("editor--myFontSize")
})

test('Editor panel has no AXE violations', async () => {
const axeResults = await axe(editor)
expect(axeResults).toHaveNoViolations()
})
})

0 comments on commit 2c91cf6

Please sign in to comment.