Repository: manusa/electronim
Pull request #455 (2024-12-04 08:25:54)

🐛 prevent context-menu from automatically closing

sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=manusa_electronim&pullRequest=455) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=455&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=455&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=manusa_electronim&pullRequest=455&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=manusa_electronim&pullRequest=455&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=manusa_electronim&pullRequest=455&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=manusa_electronim&pullRequest=455)



Patch:
diff --git a/src/tab-manager/context-menu.js b/src/tab-manager/context-menu.js
index 1131141..966d4b4 100644
--- a/src/tab-manager/context-menu.js
+++ b/src/tab-manager/context-menu.js
@@ -89,7 +89,7 @@ const handleContextMenu = viewOrWindow => async (_event, params) => {
     menu = regularContextMenu({webContents, params});
   }
   const {x, y} = params;
-  menu.popup({x, y});
+  menu.popup({x: x + 1, y: y + 1});
 };
 
 module.exports = {handleContextMenu};


Test patch:
diff --git a/src/tab-manager/__tests__/context-menu.test.js b/src/tab-manager/__tests__/context-menu.test.js
index c64e6eb..7f1c3dc 100644
--- a/src/tab-manager/__tests__/context-menu.test.js
+++ b/src/tab-manager/__tests__/context-menu.test.js
@@ -58,7 +58,7 @@ describe('Tab Manager context-menu test suite', () => {
       await listeners['context-menu'](event, params);
       // Then
       expect(electron.Menu).toHaveBeenCalledTimes(1);
-      expect(mockMenu.popup).toHaveBeenCalledWith({x: 13, y: 37});
+      expect(mockMenu.popup).toHaveBeenCalledWith({x: 14, y: 38});
     });
     describe('with native spellcheck', () => {
       beforeEach(() => {
@@ -97,9 +97,9 @@ describe('Tab Manager context-menu test suite', () => {
       params.editFlags = {};
       await listeners['context-menu'](event, params);
     });
-    test('should popup a menu at the specified location', async () => {
+    test('should popup a menu at the specified location (x+1, y+1)', async () => {
       expect(electron.Menu).toHaveBeenCalledTimes(1);
-      expect(mockMenu.popup).toHaveBeenCalledWith({x: 13, y: 37});
+      expect(mockMenu.popup).toHaveBeenCalledWith({x: 14, y: 38});
     });
     test.each(['Back', 'Reload', 'Cut', 'Copy', 'Copy image', 'Paste', 'DevTools'])(
       'adds MenuItem with label %s', async label => {