Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/controllers/file-patch-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -38,12 +47,13 @@ export default class FilePatchController {
render () {
const hunks = this.props.filePatch.getHunks()
if (!hunks.length) {
return <div className='git-PaneView pane-item is-blank'><span className='icon icon-info'>File has no contents</span></div>
return <div className='git-PaneView pane-item is-blank' tabIndex='-1'><span className='icon icon-info'>File has no contents</span></div>
} else {
// NOTE: Outer div is required for etch to render elements correctly
return (
<div className='git-PaneView pane-item'>
<div className='git-PaneView pane-item' tabIndex='-1'>
<FilePatchView
focused={this.focused}
ref='filePatchView'
stageHunk={this.stageHunk}
unstageHunk={this.unstageHunk}
Expand Down
2 changes: 1 addition & 1 deletion lib/github-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default class GithubPackage {
}

focusFilePatchView () {
this.filePatchController.refs.filePatchView.element.focus()
this.filePatchController.refs.filePatchView.focus()
}

async showMergeConflictFileForPath (relativeFilePath, {focus} = {}) {
Expand Down
10 changes: 9 additions & 1 deletion lib/views/file-patch-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ export default class FilePatchView {
const headLine = this.selection.getHeadLine()
const hunkSelectionMode = this.selection.getMode() === 'hunk'
const stageButtonLabelPrefix = this.props.stagingStatus === 'unstaged' ? 'Stage' : 'Unstage'
let classes = 'git-FilePatchView'
if (this.props.focused) {
classes += ' focused'
}
return (
<div className='git-FilePatchView' tabIndex='-1'
<div className={classes} tabIndex='-1'
onmouseup={this.mouseup}>
{this.props.hunks.map((hunk) => {
const isSelected = selectedHunks.has(hunk)
Expand Down Expand Up @@ -83,6 +87,10 @@ export default class FilePatchView {
)
}

focus () {
this.element.focus()
}

mousedownOnHeader (hunk) {
this.selection.selectHunk(hunk)
this.mouseSelectionInProgress = true
Expand Down