Skip to content

Commit

Permalink
Switch to contenteditable inputStyle, for a11y
Browse files Browse the repository at this point in the history
  • Loading branch information
aomarks committed Apr 9, 2021
1 parent ae0ba03 commit 99aadc9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
<!-- ### Fixed -->
<!-- ### Removed -->

<!-- ## Unreleased -->
## Unreleased

### Changed

- The editor now uses the CodeMirror `contenteditable` input style, which has
much better screen reader support.

## [0.8.0] - 2021-04-02

Expand Down
1 change: 1 addition & 0 deletions src/playground-code-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export class PlaygroundCodeEditor extends LitElement {
lineNumbers: this.lineNumbers,
mode: this._getLanguageMode(),
readOnly: this.readonly,
inputStyle: 'contenteditable',
}
);
cm.on('change', () => {
Expand Down
22 changes: 22 additions & 0 deletions src/test/playground-ide_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,26 @@ suite('playground-ide', () => {
};
await assertPreviewContains('Hello HTML');
});

test('a11y: is contenteditable', async () => {
const ide = document.createElement('playground-ide')!;
ide.config = {
files: {
'index.html': {
content: 'Foo\nBar',
},
},
};
container.appendChild(ide);
await assertPreviewContains('Foo');

const cmCode = await pierce(
'playground-ide',
'playground-file-editor',
'playground-code-editor',
'.CodeMirror-code'
);

assert.equal(cmCode.getAttribute('contenteditable'), 'true');
});
});

0 comments on commit 99aadc9

Please sign in to comment.