Skip to content

Commit

Permalink
HtmlEditor: add aria-readonly attribute if readOnly property is initi…
Browse files Browse the repository at this point in the history
…ally set to true (T1248155) (#27990)
  • Loading branch information
nikkithelegendarypokemonster authored Sep 6, 2024
1 parent 22ff217 commit abd451a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ const HtmlEditor = Editor.inherit({
this._prepareConverters();

this.callBase();
this._toggleReadOnlyState();
},

_prepareQuillRegistrator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,44 @@ export default function() {
});

QUnit.module('Accessibility', () => {
test('aria-readonly should be set on initialization if readOnly=true (T1248155)', function(assert) {
const $element = $('#htmlEditor');

$element.dxHtmlEditor({
readOnly: true
});

const $editorContent = $element.find(`.${HTML_EDITOR_CONTENT_CLASS}`);
const isQuillRendered = !!$editorContent.length;

assert.expect(isQuillRendered ? 1 : 0);

if(isQuillRendered) {
assert.strictEqual($editorContent.attr('aria-readonly'), 'true', 'aria-readonly is set on initialization');
}
});

test('aria-readonly should be set if readOnly property is set to true on runtime (T1248155) (T1248155)', function(assert) {
const $element = $('#htmlEditor');

$element.dxHtmlEditor({
readOnly: false
});
const instance = $element.dxHtmlEditor('instance');

const $editorContent = $element.find(`.${HTML_EDITOR_CONTENT_CLASS}`);
const isQuillRendered = !!$editorContent.length;

assert.expect(isQuillRendered ? 2 : 0);

if(isQuillRendered) {
assert.strictEqual($editorContent.attr('aria-readonly'), undefined, 'aria-readonly is properly set on initialization');

instance.option('readOnly', true);
assert.strictEqual($editorContent.attr('aria-readonly'), 'true', 'aria-readonly is properly set on runtime');
}
});

test('accessibility roles', function(assert) {
const $element = $('#htmlEditor');

Expand Down

0 comments on commit abd451a

Please sign in to comment.