Skip to content

Commit a8d985d

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat/move-tab-to-existing-window
2 parents ed8a88e + 131e240 commit a8d985d

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

content_scripts/link_hints.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ const HintCoordinator = {
164164
localHints: null,
165165
cacheAllKeydownEvents: null,
166166

167+
// A WeakRef to the last clicked element. We track this so that we can mouse of it if the user
168+
// types ESC after clicking on it. See #3073.
169+
lastClickedElementRef: null,
170+
167171
// Returns if the HintCoordinator will handle a given LinkHintsMessage.
168172
// Some messages will not be handled in the case where the help dialog is shown, and is then
169173
// hidden, but is still receiving link hints messages via broadcastLinkHintsMessage.
@@ -290,6 +294,15 @@ const HintCoordinator = {
290294
}
291295
this.linkHintsMode = this.localHints = null;
292296
},
297+
298+
mouseOutOfLastClickedElement() {
299+
if (this.lastClickedElementRef == null) return;
300+
const el = this.lastClickedElementRef.deref();
301+
if (el) {
302+
DomUtils.simulateMouseEvent("mouseout", el, null);
303+
}
304+
this.lastClickedElementRef = null;
305+
},
293306
};
294307

295308
const LinkHints = {
@@ -680,6 +693,7 @@ class LinkHintsMode {
680693
if (["input", "select", "object", "embed"].includes(clickEl.nodeName.toLowerCase())) {
681694
clickEl.focus();
682695
}
696+
HintCoordinator.lastClickedElementRef = new WeakRef(clickEl);
683697
return linkActivator(clickEl);
684698
}
685699
}

content_scripts/mode_key_handler.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,14 @@ class KeyHandlerMode extends Mode {
6262
const isEscape = KeyboardUtils.isEscape(event);
6363
if (isEscape && ((this.countPrefix !== 0) || (this.keyState.length !== 1))) {
6464
return DomUtils.consumeKeyup(event, () => this.reset());
65-
// If the help dialog loses the focus, then Escape should hide it; see point 2 in #2045.
6665
} else if (isEscape && HelpDialog && HelpDialog.isShowing()) {
66+
// If the help dialog loses the focus, then Escape should hide it; see point 2 in #2045.
6767
HelpDialog.toggle();
6868
return this.suppressEvent;
6969
} else if (isEscape) {
70+
// Some links stay "open" after clicking, until you mouse off of them, like Wikipedia's link
71+
// preview popups. If the user types escape, issue a mouseout event here. See #3073.
72+
HintCoordinator.mouseOutOfLastClickedElement();
7073
return this.continueBubbling;
7174
} else if (this.isMappedKey(keyChar)) {
7275
this.handleKeyChar(keyChar);

content_scripts/mode_visual.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ class VisualMode extends KeyHandlerMode {
271271
this.onExit((event = null) => {
272272
// Retain any selection, regardless of how we exit.
273273
if (this.shouldRetainSelectionOnExit) {
274-
null;
275274
// This mimics vim: when leaving visual mode via Escape, collapse to focus, otherwise
276275
// collapse to anchor.
277276
} else if (

lib/handler_stack.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ class HandlerStack {
4848
// @passEventToPage.
4949
bubbleEvent(type, event) {
5050
this.eventNumber += 1;
51-
const {
52-
eventNumber,
53-
} = this;
51+
const eventNumber = this.eventNumber;
5452
for (const handler of this.stack.slice().reverse()) {
5553
// A handler might have been removed (handler.id == null), so check; or there might just be no
5654
// handler for this type of event.

make.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --allow-net --allow-run --unstable
2-
// --unstable is required for Puppeteer.
1+
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --allow-net --allow-run
32
// Usage: ./make.js command. Use -l to list commands.
43
// This is a set of tasks for building and testing Vimium in development.
54
import * as fs from "https://deno.land/[email protected]/fs/mod.ts";

0 commit comments

Comments
 (0)