From c1743d31f625c9b25bfe843d909b4633327b5655 Mon Sep 17 00:00:00 2001 From: f321x Date: Mon, 7 Sep 2026 15:47:38 +0200 Subject: [PATCH] qml: close keyboard when tapping on ElDialog background When showing the keyboard over an ElDialog (e.g. when entering a comment into the lnurlpay dialog) it can only be closed using the android back button or the little "hide keyboard" button in the os system bar. Instead it is nicer if it is also possible to close the keyboard by clicking on some empty area of the dialog. Keep focus on contentItem so the wizards back button hook keeps working. --- electrum/gui/qml/components/controls/ElDialog.qml | 9 +++++++++ electrum/gui/qml/components/wizard/Wizard.qml | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/electrum/gui/qml/components/controls/ElDialog.qml b/electrum/gui/qml/components/controls/ElDialog.qml index b90402c9e8ee..9873e8e8c77f 100644 --- a/electrum/gui/qml/components/controls/ElDialog.qml +++ b/electrum/gui/qml/components/controls/ElDialog.qml @@ -50,6 +50,15 @@ Dialog { ? Popup.CloseOnEscape | Popup.CloseOnPressOutside : Popup.NoAutoClose + TapHandler { // close keyboard when tapping on the empty background + parent: abstractdialog.background + onTapped: { + // Release input focus so tapping the same field opens the keyboard again. + abstractdialog.contentItem.forceActiveFocus(Qt.MouseFocusReason) + Qt.inputMethod.hide() + } + } + onOpenedChanged: { if (opened) { app.activeDialogs.push(abstractdialog) diff --git a/electrum/gui/qml/components/wizard/Wizard.qml b/electrum/gui/qml/components/wizard/Wizard.qml index 5605a148679e..009f87e899d1 100644 --- a/electrum/gui/qml/components/wizard/Wizard.qml +++ b/electrum/gui/qml/components/wizard/Wizard.qml @@ -102,8 +102,8 @@ ElDialog { return page } - ColumnLayout { - anchors.fill: parent + // make layout contentItem so ElDialog TapHandler can focus on it and the Keys hook stays active + contentItem: ColumnLayout { spacing: 0 // root Item in Wizard, capture back button here and delegate to main