[gnome-shell-extensions] workspace-indicator: Fix cancelling editing with Esc



commit 8dd8d6f56104f9697cdf432bdec30854fd9ee337
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jan 6 01:30:27 2022 +0100

    workspace-indicator: Fix cancelling editing with Esc
    
    The CallbackAction's callback must return true to stop the event
    from propagating to the dialog, where it will trigger the close
    binding.
    
    It makes sense to still allow closing the dialog with Escape while
    not editing a row. The easiest way to achieve that is by moving the
    controller to the entry.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/208>

 extensions/workspace-indicator/prefs.js | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js
index 807ab7b..e7264ea 100644
--- a/extensions/workspace-indicator/prefs.js
+++ b/extensions/workspace-indicator/prefs.js
@@ -120,13 +120,6 @@ class WorkspaceRow extends Gtk.ListBoxRow {
     _init(name) {
         super._init({ name });
 
-        const controller = new Gtk.ShortcutController();
-        controller.add_shortcut(new Gtk.Shortcut({
-            trigger: Gtk.ShortcutTrigger.parse_string('Escape'),
-            action: Gtk.CallbackAction.new(this._stopEdit.bind(this)),
-        }));
-        this.add_controller(controller);
-
         const box = new Gtk.Box({
             spacing: 12,
             margin_top: 6,
@@ -156,6 +149,16 @@ class WorkspaceRow extends Gtk.ListBoxRow {
             max_width_chars: 25,
         });
 
+        const controller = new Gtk.ShortcutController();
+        controller.add_shortcut(new Gtk.Shortcut({
+            trigger: Gtk.ShortcutTrigger.parse_string('Escape'),
+            action: Gtk.CallbackAction.new(() => {
+                this._stopEdit();
+                return true;
+            }),
+        }));
+        this._entry.add_controller(controller);
+
         this._stack = new Gtk.Stack();
         this._stack.add_named(box, 'display');
         this._stack.add_named(this._entry, 'edit');


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]