notes view: make opening the editor on double-click opt-in

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>
This commit is contained in:
Thomas Lamprecht 2024-04-20 17:22:05 +02:00
parent bb5cc876ef
commit f646c22a67

View File

@ -112,7 +112,23 @@ Ext.define('Proxmox.panel.NotesView', {
listeners: { listeners: {
render: function(c) { render: function(c) {
let me = this; 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() { afterlayout: function() {
let me = this; let me = this;