From 7a3531c409d72c42bab5e5fb0e6ec3de97ab777a Mon Sep 17 00:00:00 2001 From: Sebastian Herrmann Date: Tue, 19 Jun 2018 20:12:55 +0200 Subject: [PATCH] Propagate tabindex prop to editor's scroll container (#338) * 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 https://github.com/zenoamaro/react-quill/issues/232#issuecomment-369199337 * Update component.js --- src/component.js | 15 ++++++++------- src/mixin.js | 9 +++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/component.js b/src/component.js index d39d0462..634bae4e 100644 --- a/src/component.js +++ b/src/component.js @@ -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, }; }, diff --git a/src/mixin.js b/src/mixin.js index 56b2e451..dde09f17 100644 --- a/src/mixin.js +++ b/src/mixin.js @@ -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; }, @@ -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,