Skip to content

Commit 07f7571

Browse files
authored
fix(ui): Tabs > prevent middle click from pasting clipboard text into focused body (#379)
1 parent 3d5b384 commit 07f7571

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

packages/ui/src/components/TabBar.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
:class="{ 'tab-active': activeTab && activeTab._id === tab._id }"
1010
v-for="tab in tabs"
1111
@click="setActiveTab(tab)"
12-
@mousedown.middle.prevent="closeTab(tab)"
12+
@mousedown.middle.prevent.stop
13+
@mouseup.middle.prevent.stop="closeTab(tab)"
1314
:data-id="tab._id"
1415
draggable="true"
1516
@contextmenu.prevent="handleTabContextMenu($event, tab)"

packages/ui/tests/App_test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,24 @@ Scenario('Test env var autocompletion', async() => {
119119
await checkAutocompleteInBetween('{{ca}}', '{{ca', 't', '{{cat}}')
120120
await checkAutocompleteInBetween('ca}}', 'ca', 't', '{{cat}}')
121121
})
122+
123+
Scenario('Middle clicking a tab should not paste clipboard text into focused body', async ({ I }) => {
124+
const bodyTab = '[data-testid="request-panel-tab-Body"]';
125+
126+
I.createRequest('Tab1');
127+
I.click(bodyTab);
128+
129+
I.createGraphQLRequest('Tab2');
130+
I.fillRequestBody
131+
132+
await I.fillRequestBody('Tab2 text');
133+
134+
I.click('.code-mirror-editor .cm-content');
135+
136+
await I.middleClickTab('Tab1');
137+
138+
I.dontSee('Tab1', '.tab');
139+
140+
const currentText = await I.getRequestBodyText();
141+
I.expectEqual(currentText.trim() === 'Tab2 text', true);
142+
});

packages/ui/tests/steps_file.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,28 @@ export = function() {
4343
this.fillField('.code-mirror-editor .cm-content', JSON.stringify(obj))
4444
this.click('Done')
4545
},
46+
47+
async middleClickTab(name: string) {
48+
await this.usePlaywrightTo('middle click tab', async ({ page }) => {
49+
await page.locator('.tab').filter({ hasText: name }).click({ button: 'middle' });
50+
});
51+
},
52+
53+
async fillRequestBody(text: string) {
54+
this.click('.code-mirror-editor .cm-content')
55+
this.pressKey(['CommandOrControl', 'A'])
56+
this.pressKey('Backspace')
57+
this.type(text)
58+
},
59+
60+
async getRequestBodyText() {
61+
return await this.grabTextFrom('.code-mirror-editor .cm-content')
62+
},
63+
64+
async selectAllAndCopy() {
65+
this.click('.code-mirror-editor .cm-content')
66+
this.pressKey(['CommandOrControl', 'A'])
67+
this.pressKey(['CommandOrControl', 'C'])
68+
},
4669
})
4770
}

0 commit comments

Comments
 (0)