Skip to content

Commit 8f55dc1

Browse files
shakyShanegreyivy
andauthored
ntp: send background-tab on windows middle-click (#1595)
* ntp: send background-tab on windows middle-click * Consistency, macOS compatability * Remove unused test * Fix test * Fix test * (Sorry, I can't run integration tests locally) * Last fix --------- Co-authored-by: Ivy Grey <[email protected]>
1 parent 719673e commit 8f55dc1

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

special-pages/pages/history/integration-tests/history.page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class HistoryTestPage {
204204

205205
expect(calls[3].payload.params).toStrictEqual({
206206
url,
207-
target: 'new-window',
207+
target: 'new-tab',
208208
});
209209
}
210210

special-pages/pages/new-tab/app/activity/integration-tests/activity.page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class ActivityPage {
213213

214214
expect(calls[3].payload.params).toStrictEqual({
215215
url,
216-
target: 'new-window',
216+
target: 'new-tab',
217217
});
218218
}
219219

special-pages/pages/new-tab/app/favorites/integration-tests/favorites.page.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ export class FavoritesPage {
2020

2121
async opensInNewTab() {
2222
await this.nthFavorite(0).click({ modifiers: ['Meta'] });
23+
await this.nthFavorite(0).click({ button: 'middle' });
2324
const calls = await this.ntp.mocks.waitForCallCount({ method: 'favorites_open', count: 1 });
2425
expect(calls[0].payload.params).toStrictEqual({ id: 'id-many-1', url: 'https://example.com/?id=id-many-1', target: 'new-tab' });
26+
expect(calls[1].payload.params).toStrictEqual({ id: 'id-many-1', url: 'https://example.com/?id=id-many-1', target: 'new-tab' });
2527
}
2628

2729
async opensInNewWindow() {
2830
await this.nthFavorite(0).click({ modifiers: ['Shift'] });
29-
await this.nthFavorite(0).click({ button: 'middle' });
30-
const calls = await this.ntp.mocks.waitForCallCount({ method: 'favorites_open', count: 2 });
31+
const calls = await this.ntp.mocks.waitForCallCount({ method: 'favorites_open', count: 1 });
3132
expect(calls[0].payload.params).toStrictEqual({ id: 'id-many-1', url: 'https://example.com/?id=id-many-1', target: 'new-window' });
32-
expect(calls[1].payload.params).toStrictEqual({ id: 'id-many-1', url: 'https://example.com/?id=id-many-1', target: 'new-window' });
3333
}
3434

3535
async opensInSameTab() {

special-pages/pages/new-tab/app/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ export function eventToTarget(event, platformName) {
7070
const isControlClick = platformName === 'macos' ? event.metaKey : event.ctrlKey;
7171
if (isControlClick) {
7272
return 'new-tab';
73-
} else if (event.shiftKey || event.button === 1 /* middle click */) {
73+
} else if (event.shiftKey) {
7474
return 'new-window';
75+
} else if (event.button === 1 /* middle click */) {
76+
return 'new-tab';
7577
}
7678
return 'same-tab';
7779
}

special-pages/shared/handlers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66
export function eventToTarget(event, platformName) {
77
const isControlClick = platformName === 'macos' ? event.metaKey : event.ctrlKey;
8-
if (isControlClick) {
8+
if (isControlClick || ('button' in event && event.button === 1) /* middle click */) {
99
return 'new-tab';
10-
} else if (event.shiftKey || ('button' in event && event.button === 1) /* middle click */) {
10+
} else if (event.shiftKey) {
1111
return 'new-window';
1212
}
1313
return 'same-tab';

0 commit comments

Comments
 (0)