[geary/geary-0.12] Prevent composer body/sig/quote parts from losing focus. Bug 779369.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/geary-0.12] Prevent composer body/sig/quote parts from losing focus. Bug 779369.
- Date: Sat, 2 Dec 2017 09:47:32 +0000 (UTC)
commit f5c6a06dcbfc5c39be9a88c31beedfd894ffc688
Author: Michael James Gratton <mike vee net>
Date: Thu Nov 16 15:49:51 2017 +1100
Prevent composer body/sig/quote parts from losing focus. Bug 779369.
* ui/composer-web-view.js: Add a click handler for the document that
prevents clicks outside the body parts from being processed.
ui/composer-web-view.js | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/ui/composer-web-view.js b/ui/composer-web-view.js
index 63cea8e..2a53b6e 100644
--- a/ui/composer-web-view.js
+++ b/ui/composer-web-view.js
@@ -59,7 +59,19 @@ ComposerPageState.prototype = {
let state = this;
this.bodyPart = document.getElementById("geary-body");
- if (this.bodyPart == null) {
+ if (this.bodyPart != null) {
+ // Capture clicks on the document that aren't on an
+ // existing part and prevent focus leaving it. Bug 779369.
+ document.addEventListener("mousedown", function(e) {
+ if (!state.containedInPart(e.target)) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ });
+ } else {
+ // This happens if we are loading a draft created by a MUA
+ // that isn't Geary, so we can't rely on any of the
+ // expected HTML structure to be in place.
this.bodyPart = document.body;
}
@@ -381,6 +393,16 @@ ComposerPageState.prototype = {
this.focusedPart = newFocus;
this.focusedPart.classList.add("geary-focus");
}
+ },
+ containedInPart: function(target) {
+ let inPart = false;
+ for (let part of [this.bodyPart, this.quotePart, this.signaturePart]) {
+ if (part != null && (part == target || part.contains(target))) {
+ inPart = true;
+ break;
+ }
+ }
+ return inPart;
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]