diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 6f3f6eb1f..b9cd3e3a0 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -918,8 +918,10 @@ describe "EditorComponent", -> expect(document.activeElement).toBe document.body inputNode.focus() expect(node.classList.contains('is-focused')).toBe true + expect(wrapperView.hasClass('is-focused')).toBe true inputNode.blur() expect(node.classList.contains('is-focused')).toBe false + expect(wrapperView.hasClass('is-focused')).toBe false describe "selection handling", -> cursor = null diff --git a/src/editor-component.coffee b/src/editor-component.coffee index b2801017c..b46a1dc5e 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -170,6 +170,7 @@ EditorComponent = React.createClass componentDidUpdate: (prevProps, prevState) -> @pendingChanges.length = 0 @refreshingScrollbars = false + @updateParentViewFocusedClassIfNeeded(prevState) @measureScrollbars() if @measuringScrollbars @measureLineHeightAndCharWidthsIfNeeded(prevState) @pauseOverflowChangedEvents() @@ -784,3 +785,7 @@ EditorComponent = React.createClass top = clientY - scrollViewClientRect.top + editor.getScrollTop() left = clientX - scrollViewClientRect.left + editor.getScrollLeft() {top, left} + + updateParentViewFocusedClassIfNeeded: (prevState) -> + if prevState.focused isnt @state.focused + @props.parentView.toggleClass('is-focused', @props.focused)