Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
Refocus after application of Code Action (#152)
Browse files Browse the repository at this point in the history
Summary:
Imports facebookarchive/atom-ide-ui#152.

It's a small PR to give the editor focus after clicking a code action (to avoid a situation where nothing has focus).

Reviewed By: matthewwithanm

Differential Revision: D6788648

fbshipit-source-id: 406705d6d2b513652489f9d353779f48d81edac9
  • Loading branch information
hansonw authored and facebook-github-bot committed Jan 23, 2018
1 parent 9a5c5b9 commit 7b7de4b
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import type {CodeAction} from '../../../atom-ide-code-actions/lib/types';

import {TextEditor} from 'atom';
import * as React from 'react';
import {Button} from 'nuclide-commons-ui/Button';
import {ButtonGroup} from 'nuclide-commons-ui/ButtonGroup';
Expand All @@ -35,7 +36,16 @@ export default function DiagnosticsCodeActions(props: {
size="EXTRA_SMALL"
onClick={() => {
// TODO: (seansegal) T21130332 Display CodeAction status indicators
codeAction.apply().catch(handleCodeActionFailure);
codeAction
.apply()
.catch(handleCodeActionFailure)
.then(() => {
// Return focus to the editor after clicking.
const activeItem = atom.workspace.getActivePaneItem();
if (activeItem && activeItem instanceof TextEditor) {
activeItem.element.focus();
}
});
}}>
<span className="inline-block">{title}</span>
</Button>
Expand Down

0 comments on commit 7b7de4b

Please sign in to comment.