mirror of
https://github.com/desktop/desktop
synced 2024-08-27 12:11:00 +00:00
Fix keyboard navigation in PR list
This commit is contained in:
parent
2350aef5d8
commit
4305612427
|
@ -55,8 +55,14 @@ interface IBranchesContainerProps {
|
|||
}
|
||||
|
||||
interface IBranchesContainerState {
|
||||
readonly selectedBranch: Branch | null
|
||||
/**
|
||||
* A copy of the last seen currentPullRequest property
|
||||
* from props. Used in order to be able to detect when
|
||||
* the selected PR in props changes in getDerivedStateFromProps
|
||||
*/
|
||||
readonly currentPullRequest: PullRequest | null
|
||||
readonly selectedPullRequest: PullRequest | null
|
||||
readonly selectedBranch: Branch | null
|
||||
readonly branchFilterText: string
|
||||
}
|
||||
|
||||
|
@ -65,12 +71,27 @@ export class BranchesContainer extends React.Component<
|
|||
IBranchesContainerProps,
|
||||
IBranchesContainerState
|
||||
> {
|
||||
public static getDerivedStateFromProps(
|
||||
props: IBranchesContainerProps,
|
||||
state: IBranchesContainerProps
|
||||
): Partial<IBranchesContainerState> | null {
|
||||
if (state.currentPullRequest !== props.currentPullRequest) {
|
||||
return {
|
||||
currentPullRequest: props.currentPullRequest,
|
||||
selectedPullRequest: props.currentPullRequest,
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
public constructor(props: IBranchesContainerProps) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
selectedBranch: props.currentBranch,
|
||||
selectedPullRequest: props.currentPullRequest,
|
||||
currentPullRequest: props.currentPullRequest,
|
||||
branchFilterText: '',
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +208,7 @@ export class BranchesContainer extends React.Component<
|
|||
<PullRequestList
|
||||
key="pr-list"
|
||||
pullRequests={this.props.pullRequests}
|
||||
selectedPullRequest={this.props.currentPullRequest}
|
||||
selectedPullRequest={this.state.selectedPullRequest}
|
||||
isOnDefaultBranch={!!isOnDefaultBranch}
|
||||
onSelectionChanged={this.onPullRequestSelectionChanged}
|
||||
onCreateBranch={this.onCreateBranch}
|
||||
|
|
Loading…
Reference in a new issue