From e4bde2d29ffdece67ffaef6f237b6b1987961df1 Mon Sep 17 00:00:00 2001 From: Duff Date: Mon, 29 Apr 2024 09:11:48 +0200 Subject: [PATCH] fix #71 closePopup (#76) --- .eslintrc.js | 2 ++ CHANGES.md | 4 ++++ addon/popup.js | 25 ++++++++++++++++++------- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 51ff7eab..e53b6f25 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,5 @@ +/* eslint-env node */ + module.exports = { "env": { "browser": true, diff --git a/CHANGES.md b/CHANGES.md index 1acc46a9..769fbc2f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Release Notes +## Version 1.26 + +- Escape to close popup [issue 71](https://github.com/dufoli/Salesforce-Inspector-Advanced/issues/71) + ## Version 1.25 - Metadata: download data model by @dufoli in [issue 11](https://github.com/dufoli/Salesforce-Inspector-Advanced/issues/11) diff --git a/addon/popup.js b/addon/popup.js index 2ed911c0..c63a2d39 100644 --- a/addon/popup.js +++ b/addon/popup.js @@ -131,6 +131,7 @@ class App extends React.PureComponent { onShortcutKey(e) { const refs = this.refs; const actionMap = { + "Escape": ["closePopup", ""], "m": ["all", "clickShowDetailsBtn"], "a": ["all", "clickAllDataBtn"], "f": ["all", "clickShowFieldAPINameBtn"], @@ -152,14 +153,24 @@ class App extends React.PureComponent { } e.preventDefault(); const [action, target] = actionMap[e.key]; - if (action === "all") { - refs.showAllDataBox.refs?.showAllDataBoxSObject?.[target](); - } else if (action === "click" && refs[target]) { - refs[target].target = getLinkTarget(e); - refs[target].click(); - } else if (action === "tab") { - refs.showAllDataBox.refs[target].click(); + switch (action) { + case "closePopup": + closePopup(); + return; + case "all": + refs.showAllDataBox.refs?.showAllDataBoxSObject?.[target](); + break; + case "click": + if (refs[target]) { + refs[target].target = getLinkTarget(e); + refs[target].click(); + } + break; + case "tab": + refs.showAllDataBox.refs[target].click(); + break; } + if (e.key == "p") { e.preventDefault(); this.refs.apexRunnerBtn.target = getLinkTarget(e);