]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
notes view: make opening the editor on double-click opt-in
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 20 Apr 2024 15:22:05 +0000 (17:22 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 20 Apr 2024 15:26:48 +0000 (17:26 +0200)
One can get some smart-selection behavior when double clicking text in
browsers, e.g., whole-word selection, and the notes view is generally
for having some text that is often copied, like hostnames or IP
addresses.

Opening the notes editor on double click is interfering with that
select+copy workflow, so instead of hard-coding that make it opt-in,
controlled by a setting from the browser-local storage.

Add some handling to cope with live-changes to that setting, as having
to re-open a panel to make it take effect is annoying and might make
people believe that this is buggy.

This new setting has (currently) to be handled by the per-product UI.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/panel/NotesView.js

index 5cbef8be45c3926954ba24ed6fdaad4c15ab1dc3..6680f2256bef4660a2edd97995e8ff9a338e1186 100644 (file)
@@ -112,7 +112,23 @@ Ext.define('Proxmox.panel.NotesView', {
     listeners: {
        render: function(c) {
            let me = this;
-           me.getEl().on('dblclick', me.run_editor, me);
+           let sp = Ext.state.Manager.getProvider();
+           // to cover live changes to the browser setting
+           me.mon(sp, 'statechange', function(provider, key, value) {
+               if (value === null || key !== 'edit-notes-on-double-click') {
+                   return;
+               }
+               if (value) {
+                   me.getEl().on('dblclick', me.run_editor, me);
+               } else {
+                   // there's only the me.run_editor listener, and removing just that did not work
+                   me.getEl().clearListeners();
+               }
+           });
+           // to cover initial setting value
+           if (sp.get('edit-notes-on-double-click', false)) {
+               me.getEl().on('dblclick', me.run_editor, me);
+           }
        },
        afterlayout: function() {
            let me = this;