Skip to content

Commit

Permalink
Propagate tabindex prop to editor's scroll container (zenoamaro#338)
Browse files Browse the repository at this point in the history
* Propagate tabindex prop to editor's scroll container

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)

* Update component.js
  • Loading branch information
herrherrmann authored and alexkrolick committed Jun 19, 2018
1 parent a795638 commit 7a3531c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,14 @@ var QuillComponent = createClass({

getEditorConfig: function() {
return {
bounds: this.props.bounds,
formats: this.props.formats,
modules: this.props.modules,
placeholder: this.props.placeholder,
readOnly: this.props.readOnly,
theme: this.props.theme,
scrollingContainer: this.props.scrollingContainer,
bounds: this.props.bounds,
formats: this.props.formats,
modules: this.props.modules,
placeholder: this.props.placeholder,
readOnly: this.props.readOnly,
scrollingContainer: this.props.scrollingContainer,
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 7a3531c

Please sign in to comment.