Skip to content

Commit

Permalink
[popup] Add option to open extension pages in new tab using keyboard …
Browse files Browse the repository at this point in the history
…shortcuts (#158)

**Description**
In the current implementation, navigating to the Export and Import pages
through keyboard shortcuts (`Ctrl+Option+I` on Mac or `Ctrl+Alt+I` on
Windows, followed by `E` or `I`) only allows users to open these pages
in the current tab.
Opening these pages in the current tab disrupts the user flow
In order to open the page in a new tab, users have to resort to using a
combination of keyboard commands and mouse clicks which is not ideal.
(control or command + mouse click).

**Enhancement**
This pull request introduces an enhancement to the existing keyboard
shortcut functionalities, allowing users to open the extension pages in
a new tab seamlessly. By holding the Command key (on Mac) or Control key
(on Windows) in conjunction with the existing shortcut keys, users can
now open the extension pages in a new tab, thereby preserving their
position on the current page and facilitating a smoother navigation
experience.

**Testing**
This feature has been tested across different environments to ensure
compatibility and smooth integration with existing functionalities. I
encourage further testing to validate its efficiency and usability
enhancements.

**Request for Review**
I kindly request a review of this pull request and am open to making any
necessary adjustments based on your feedback. Thank you for considering
this valuable enhancement to the user experience.

---------

Co-authored-by: user <[email protected]>
Co-authored-by: Thomas Prouvot <[email protected]>
  • Loading branch information
3 people authored Sep 27, 2023
1 parent 7c39032 commit b652608
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## General


- Add option to open extension pages in a new tab using keyboard shortcuts (contribution by [Joshua Yarmak](https://github.com/toly11))
- Add customizable query templates to query export page (idea and co-develop with [Samuel Krissi](https://github.com/samuelkrissi))
- Explore-api page restyling
- Ability to define csv-file separator [feature 144](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/144) (issue by [Reinier van den Assum](https://github.com/foxysolutions))
Expand Down
19 changes: 15 additions & 4 deletions addon/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,32 @@ class App extends React.PureComponent {
}
if (e.key == "e") {
e.preventDefault();
this.refs.dataExportBtn.target = getLinkTarget(e);
this.refs.dataExportBtn.click();
}
if (e.key == "i") {
e.preventDefault();
this.refs.dataImportBtn.target = getLinkTarget(e);
this.refs.dataImportBtn.click();
}
if (e.key == "l") {
e.preventDefault();
this.refs.limitsBtn.target = getLinkTarget(e);
this.refs.limitsBtn.click();
}
if (e.key == "d") {
e.preventDefault();
this.refs.metaRetrieveBtn.click();
}
if (e.key == "d") {
e.preventDefault();
this.refs.metaRetrieveBtn.target = getLinkTarget(e);
this.refs.metaRetrieveBtn.click();
}
if (e.key == "x") {
e.preventDefault();
this.refs.apiExploreBtn.target = getLinkTarget(e);
this.refs.apiExploreBtn.click();
}
if (e.key == "h" && this.refs.homeBtn) {
e.preventDefault();
this.refs.homeBtn.target = getLinkTarget(e);
this.refs.homeBtn.click();
}
if (e.key == "o") {
Expand Down Expand Up @@ -1608,4 +1611,12 @@ function sfLocaleKeyToCountryCode(localeKey) {
return splitted[(splitted.length > 1 && !localeKey.includes("_LATN_")) ? 1 : 0].toLowerCase();
}

function getLinkTarget(e) {
if (localStorage.getItem("openLinksInNewTab") == "true" || (e.ctrlKey || e.metaKey)){
return "_blank";
} else {
return "_top";
}
}

window.getRecordId = getRecordId; // for unit tests

0 comments on commit b652608

Please sign in to comment.