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

Commit

Permalink
Fix deprecated usages of electron$Menu.popup API
Browse files Browse the repository at this point in the history
Summary:
In Electron 2.0.0 the `menu.popup` API now only accepts options: electron/electron#11968

But this works just fine in Atom 1.25-1.27 as well, so this is a safe change.

Reviewed By: matthewwithanm

Differential Revision: D8045697

fbshipit-source-id: 9f7a3821426717998945bcf2b373710e73fdbb7f
  • Loading branch information
hansonw committed May 18, 2018
1 parent 49f6fa1 commit 52582a7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
8 changes: 4 additions & 4 deletions flow-libs/electron.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,13 @@ declare class electron$Menu {
static getApplicationMenu(): ?electron$Menu,
static sendActionToFirstResponder(action: string): void,
static buildFromTemplate(templates: Array<electron$MenuItemOptions>): electron$Menu,
popup(
browserWindow: electron$BrowserWindow,
popup({|
window?: electron$BrowserWindow,
x?: number,
y?: number,
positioningItem?: number,
): void,
popup(x?: number, y?: number, positioningItem?: number): void,
callback?: Function,
|}): void,
append(menuItem: electron$MenuItem): void,
insert(pos: number, menuItem: electron$MenuItem): void,
items: Array<electron$MenuItem>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default class PromptButton extends React.Component<Props> {
}

_handleClick = (event: SyntheticMouseEvent<>): void => {
const currentWindow = remote.getCurrentWindow();
const menu = new remote.Menu();
// TODO: Sort alphabetically by label
this.props.options.forEach(option => {
Expand All @@ -55,6 +54,6 @@ export default class PromptButton extends React.Component<Props> {
}),
);
});
menu.popup(currentWindow, event.clientX, event.clientY);
menu.popup({x: event.clientX, y: event.clientY});
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export default function showActionsMenu(
.take(1)
.race(Observable.of(new WeakMap()).delay(CODE_ACTIONS_TIMEOUT))
.subscribe(codeActionsForMessage => {
const currentWindow = remote.getCurrentWindow();
const menu = new remote.Menu();
const fixes = arrayCompact(
messagesAtPosition.map(message => {
Expand Down Expand Up @@ -96,16 +95,15 @@ export default function showActionsMenu(
const scrollView = editorView.querySelector('.scroll-view');
invariant(scrollView != null);
const boundingRect = scrollView.getBoundingClientRect();
menu.popup(
currentWindow,
Math.round(
menu.popup({
x: Math.round(
boundingRect.left + pixelPosition.left - editorView.getScrollLeft(),
),
Math.round(
y: Math.round(
boundingRect.top + pixelPosition.top - editorView.getScrollTop(),
),
0,
);
positioningItem: 0,
});
}),
);
}
3 changes: 1 addition & 2 deletions modules/nuclide-commons-ui/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ export class Dropdown extends React.Component<Props> {
}

_handleDropdownClick = (event: SyntheticMouseEvent<>): void => {
const currentWindow = remote.getCurrentWindow();
const menu = this._menuFromOptions(this.props.options);
menu.popup(currentWindow, event.clientX, event.clientY);
menu.popup({x: event.clientX, y: event.clientY});
};

_menuFromOptions(options: $ReadOnlyArray<Option>): remote.Menu {
Expand Down

0 comments on commit 52582a7

Please sign in to comment.