From 8dd8d6f56104f9697cdf432bdec30854fd9ee337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 6 Jan 2022 01:30:27 +0100 Subject: [PATCH] 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: --- 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 807ab7bb..e7264ea6 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');