From 4af11f6afae7267c717f0dcc530fbc9138b6d5fe Mon Sep 17 00:00:00 2001 From: Katrina Uychaco Date: Tue, 22 Nov 2016 18:05:21 -0800 Subject: [PATCH] WIP fix focus styling in FilePatchView --- lib/controllers/file-patch-controller.js | 14 ++++++++++++-- lib/github-package.js | 2 +- lib/views/file-patch-view.js | 10 +++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/controllers/file-patch-controller.js b/lib/controllers/file-patch-controller.js index f034bde207..10a3bc2486 100644 --- a/lib/controllers/file-patch-controller.js +++ b/lib/controllers/file-patch-controller.js @@ -20,6 +20,15 @@ export default class FilePatchController { }) this.repositoryObserver.setActiveModel(props.repository) etch.initialize(this) + + this.element.addEventListener('focus', () => { + this.focused = true + etch.update(this) + }) + this.element.addEventListener('blur', () => { + this.focused = false + etch.update(this) + }) } async update (props) { @@ -38,12 +47,13 @@ export default class FilePatchController { render () { const hunks = this.props.filePatch.getHunks() if (!hunks.length) { - return
File has no contents
+ return
File has no contents
} else { // NOTE: Outer div is required for etch to render elements correctly return ( -
+
{this.props.hunks.map((hunk) => { const isSelected = selectedHunks.has(hunk) @@ -83,6 +87,10 @@ export default class FilePatchView { ) } + focus () { + this.element.focus() + } + mousedownOnHeader (hunk) { this.selection.selectHunk(hunk) this.mouseSelectionInProgress = true