mirror of
https://github.com/zen-browser/desktop.git
synced 2026-03-31 12:51:59 +00:00
fix: allow selection within link, b=closes https://github.com/zen-browser/desktop/issues/8391, p=#11394
* fix: allow selection within link fixes: #8391 The glance feature was clashing with the possibility to select text within a link. To avoid the conflict, glance will only open upon mouseup and only if the mouse hasn't moved since the mouse was pressed. * remove redundant condition * register listeners in correct place * feat: Listen to mouse move only once, b=no-bug, c=common, glance --------- Co-authored-by: mr. m <mr.m@tuta.com>
This commit is contained in:
@@ -45,6 +45,9 @@ let JSWINDOWACTORS = {
|
||||
mousedown: {
|
||||
capture: true,
|
||||
},
|
||||
mouseup: {
|
||||
capture: true,
|
||||
},
|
||||
keydown: {
|
||||
capture: true,
|
||||
},
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
export class ZenGlanceChild extends JSWindowActorChild {
|
||||
#activationMethod;
|
||||
#glanceTarget = null;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.mousemoveCallback = this.mousemoveCallback.bind(this);
|
||||
}
|
||||
|
||||
async handleEvent(event) {
|
||||
@@ -80,11 +82,23 @@ export class ZenGlanceChild extends JSWindowActorChild {
|
||||
} else if (activationMethod === 'meta' && !event.metaKey) {
|
||||
return;
|
||||
}
|
||||
if (target) {
|
||||
this.#glanceTarget = target;
|
||||
window.addEventListener('mousemove', this.mousemoveCallback, { once: true });
|
||||
}
|
||||
|
||||
on_mouseup(event) {
|
||||
if (this.#glanceTarget) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.#openGlance(this.#glanceTarget);
|
||||
this.#glanceTarget = null;
|
||||
window.removeEventListener('mousemove', this.mousemoveCallback);
|
||||
}
|
||||
}
|
||||
|
||||
this.#openGlance(target);
|
||||
mousemoveCallback() {
|
||||
if (this.#glanceTarget) {
|
||||
this.#glanceTarget = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user