From 6b973ee9b5bf83943425091526473a0da26cae89 Mon Sep 17 00:00:00 2001 From: Kimoon Higashihira Han <98246499+kmnhan@users.noreply.github.com> Date: Wed, 29 Jul 2026 15:42:19 +0800 Subject: [PATCH] fix(options): defer typed spinbox updates --- src/erlab/interactive/_options/ui.py | 6 ++++++ tests/interactive/test_options.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/erlab/interactive/_options/ui.py b/src/erlab/interactive/_options/ui.py index d96f115fa..1b413d9b4 100644 --- a/src/erlab/interactive/_options/ui.py +++ b/src/erlab/interactive/_options/ui.py @@ -572,6 +572,12 @@ def _make_category_page(self, scope: _Scope, category: str) -> QtWidgets.QWidget for path in paths: control = self._make_control(path) + # The dialog saves and refreshes immediately after each value change. + # Defer typed numeric changes so a refresh does not interrupt entry. + if isinstance(control, QtWidgets.QAbstractSpinBox): + control.setKeyboardTracking(False) + for spin in control.findChildren(QtWidgets.QAbstractSpinBox): + spin.setKeyboardTracking(False) row = _SettingsRow(scope=scope, path=path, control=control, parent=page) self._rows[(scope, path)] = row self._connect_control(row) diff --git a/tests/interactive/test_options.py b/tests/interactive/test_options.py index fb48d9ed7..9f36f57cf 100644 --- a/tests/interactive/test_options.py +++ b/tests/interactive/test_options.py @@ -143,6 +143,13 @@ def test_dialog_native_structure(dialog: OptionDialog): assert container.layout().contentsMargins().right() > 0 +def test_dialog_spinboxes_disable_keyboard_tracking(dialog: OptionDialog): + spinboxes = dialog.findChildren(QtWidgets.QAbstractSpinBox) + + assert spinboxes + assert all(not spin.keyboardTracking() for spin in spinboxes) + + def test_dialog_setting_descriptions_are_visible_not_duplicate_tooltips( dialog: OptionDialog, ):