Disable cut/copy contextual menu items in password fields

This commit is contained in:
Ben Gotow 2018-12-30 11:47:38 -08:00
parent 1d923cf406
commit 63286cc7e2

View file

@ -301,6 +301,13 @@ export default class WindowEventHandler {
if (!textualInputs.includes(event.target.type)) {
return;
}
const supportsCutCopy = event.target.type !== 'password';
if (!supportsCutCopy) {
this.openSpellingMenuFor('', false, {});
return;
}
const hasSelectedText = event.target.selectionStart !== event.target.selectionEnd;
let wordStart = null;
let wordEnd = null;
@ -333,8 +340,10 @@ export default class WindowEventHandler {
const { Menu, MenuItem } = remote;
const menu = new Menu();
Spellchecker = Spellchecker || require('./spellchecker').default;
Spellchecker.appendSpellingItemsToMenu({ menu, word, onCorrect });
if (word) {
Spellchecker = Spellchecker || require('./spellchecker').default;
Spellchecker.appendSpellingItemsToMenu({ menu, word, onCorrect });
}
menu.append(
new MenuItem({