* [pve-devel] [PATCH widget-toolkit v2] fix: gui: up/down arrow keys increment/decrement twice in Number field
@ 2022-07-25 13:40 Daniel Tschlatscher
2022-07-29 7:24 ` [pve-devel] applied: " Dominik Csapak
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Tschlatscher @ 2022-07-25 13:40 UTC (permalink / raw)
To: pve-devel
When the up or down arrow key on the keyboard was pressed while a
number text field (or any one descending from Ext.form.field.Spinner)
was selected, the up and down callbacks for that text fields KeyNav
were called twice. Therefore, the value in the text field would always
incorrectly increment/decrement by step * 2.
The problem was an overwrite for the onRender() method of the Spinner
class, which caused the callbacks for pressing an arrow key to be
registered for a second time. Simply not doing that in the overwritten
onRender() method fixes the problem.
The redundant declarations for spinUpEl and spinDownEl were removed as
well. Additionally, the 'mousewheel' event handler, registered in the
overwritten (but still executed) parent function, is unregistered now,
as it could lead to unintended side effects in browsers which still
implement this event.
Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
---
Changes from v1:
* Changed var to let
* Additionally unregister the 'mousewheel' event handler defined in
the original ExtJS class
* Removed redundant compatiblity code (spinUpEl/spinDownEl)
src/Toolkit.js | 26 ++++----------------------
1 file changed, 4 insertions(+), 22 deletions(-)
diff --git a/src/Toolkit.js b/src/Toolkit.js
index a1d291e..ad64f89 100644
--- a/src/Toolkit.js
+++ b/src/Toolkit.js
@@ -464,35 +464,17 @@ Ext.define('Proxmox.form.field.Spinner', {
override: 'Ext.form.field.Spinner',
onRender: function() {
- var me = this,
- spinnerTrigger = me.getTrigger('spinner');
+ let me = this;
me.callParent();
- // Init up/down arrow keys
- if (me.keyNavEnabled) {
- me.spinnerKeyNav = new Ext.util.KeyNav({
- target: me.inputEl,
- scope: me,
- up: me.spinUp,
- down: me.spinDown,
- });
-
- me.inputEl.on({
- keyup: me.onInputElKeyUp,
- scope: me,
- });
- }
-
// Init mouse wheel
if (me.mouseWheelEnabled) {
+ // Unlisten Ext generated listener ('mousewheel' is deprecated anyway)
+ me.mun(me.bodyEl, 'mousewheel', me.onMouseWheel, me);
+
me.mon(me.bodyEl, 'wheel', me.onMouseWheel, me);
}
-
- // in v4 spinUpEl/spinDownEl were childEls, now they are children of the trigger.
- // create references for compatibility
- me.spinUpEl = spinnerTrigger.upEl;
- me.spinDownEl = spinnerTrigger.downEl;
},
onMouseWheel: function(e) {
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH widget-toolkit v2] fix: gui: up/down arrow keys increment/decrement twice in Number field
2022-07-25 13:40 [pve-devel] [PATCH widget-toolkit v2] fix: gui: up/down arrow keys increment/decrement twice in Number field Daniel Tschlatscher
@ 2022-07-29 7:24 ` Dominik Csapak
0 siblings, 0 replies; 2+ messages in thread
From: Dominik Csapak @ 2022-07-29 7:24 UTC (permalink / raw)
To: Proxmox VE development discussion, Daniel Tschlatscher
applied
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-29 7:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-25 13:40 [pve-devel] [PATCH widget-toolkit v2] fix: gui: up/down arrow keys increment/decrement twice in Number field Daniel Tschlatscher
2022-07-29 7:24 ` [pve-devel] applied: " Dominik Csapak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox