Skip to content

Commit

Permalink
Propagate tabindex prop to editor's scroll container
Browse files Browse the repository at this point in the history
Quill unfortunately doesn't provide an API to set the editor's
tabindex, so we have to override it directly on its dom node.
Also see zenoamaro#232 (comment)
  • Loading branch information
herrherrmann committed Feb 28, 2018
1 parent 4509e0c commit d6b4d48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ var QuillComponent = createClass({
modules: this.props.modules,
placeholder: this.props.placeholder,
readOnly: this.props.readOnly,
tabIndex: this.props.tabIndex,
theme: this.props.theme,
};
},
Expand Down
9 changes: 9 additions & 0 deletions src/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ var QuillMixin = {
*/
createEditor: function($el, config) {
var editor = new Quill($el, config);
if (config.tabIndex !== undefined) {
this.setEditorTabIndex(editor, config.tabIndex);
}
this.hookEditor(editor);
return editor;
},
Expand Down Expand Up @@ -83,6 +86,12 @@ var QuillMixin = {
editor.setSelection(range);
},

setEditorTabIndex: function(editor, tabIndex) {
if (editor.editor && editor.editor.scroll && editor.editor.scroll.domNode) {
editor.editor.scroll.domNode.tabIndex = tabIndex;
}
},

/*
Returns an weaker, unprivileged proxy object that only
exposes read-only accessors found on the editor instance,
Expand Down

0 comments on commit d6b4d48

Please sign in to comment.