* [pve-devel] [PATCH widget-toolkit] fix: gui: up/down arrow keys increment/decrement twice in Number field
@ 2022-07-07 13:41 Daniel Tschlatscher
2022-07-13 9:49 ` Dominik Csapak
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Tschlatscher @ 2022-07-07 13:41 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.
Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
---
src/Toolkit.js | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/src/Toolkit.js b/src/Toolkit.js
index a1d291e..0ce5185 100644
--- a/src/Toolkit.js
+++ b/src/Toolkit.js
@@ -469,21 +469,6 @@ Ext.define('Proxmox.form.field.Spinner', {
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) {
me.mon(me.bodyEl, 'wheel', me.onMouseWheel, me);
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pve-devel] [PATCH widget-toolkit] fix: gui: up/down arrow keys increment/decrement twice in Number field
2022-07-07 13:41 [pve-devel] [PATCH widget-toolkit] fix: gui: up/down arrow keys increment/decrement twice in Number field Daniel Tschlatscher
@ 2022-07-13 9:49 ` Dominik Csapak
0 siblings, 0 replies; 2+ messages in thread
From: Dominik Csapak @ 2022-07-13 9:49 UTC (permalink / raw)
To: Proxmox VE development discussion, Daniel Tschlatscher
man, extjs overrides are weird. i was convinced that even
the onRender gets 'overridden' and not simply called from a subclass?
anyway in that case the fix looks ok, but i think we can even go
further. since the original code will evidently be called,
how about we remove the original 'onMouseWheel' handler too?
we'd probably have to do something like:
---8<---
if (me.mouseWheelEnabled) {
me.mun(me.bodyEl, 'mousewheel', me.onMouseWheel, ...)
...
}
--->8---
(untested ofc)
i guess it works currently because the 'mousewheel' event
does not even trigger? (idk though)
also the 'spin{Up/Down}El' part at the end of the function is probably
unnecessary too since the 'callParent' call already takes care of that
On 7/7/22 15:41, Daniel Tschlatscher wrote:
> 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.
>
> Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
> ---
> src/Toolkit.js | 15 ---------------
> 1 file changed, 15 deletions(-)
>
> diff --git a/src/Toolkit.js b/src/Toolkit.js
> index a1d291e..0ce5185 100644
> --- a/src/Toolkit.js
> +++ b/src/Toolkit.js
> @@ -469,21 +469,6 @@ Ext.define('Proxmox.form.field.Spinner', {
>
> 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) {
> me.mon(me.bodyEl, 'wheel', me.onMouseWheel, me);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-13 9:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 13:41 [pve-devel] [PATCH widget-toolkit] fix: gui: up/down arrow keys increment/decrement twice in Number field Daniel Tschlatscher
2022-07-13 9:49 ` Dominik Csapak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox