From 78d79290ad156122075d38c7ba7786d13821d2fd Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Sat, 25 Mar 2023 12:58:22 +0100 Subject: [PATCH] qml: create workaround for spurious textChanged events coming from TextArea. fixes #8280 This commit also fixes a gap, where a seed text change could leave the page valid for the duration of the valid check delay timer, while the seed is actually invalid. --- .../gui/qml/components/controls/SeedTextArea.qml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/electrum/gui/qml/components/controls/SeedTextArea.qml b/electrum/gui/qml/components/controls/SeedTextArea.qml index 49c9bc25a..0047869be 100644 --- a/electrum/gui/qml/components/controls/SeedTextArea.qml +++ b/electrum/gui/qml/components/controls/SeedTextArea.qml @@ -10,12 +10,17 @@ Pane { implicitHeight: rootLayout.height padding: 0 + property string text property alias readOnly: seedtextarea.readOnly - property alias text: seedtextarea.text property alias placeholderText: seedtextarea.placeholderText property var _suggestions: [] + onTextChanged: { + if (seedtextarea.text != text) + seedtextarea.text = text + } + background: Rectangle { color: "transparent" } @@ -84,6 +89,12 @@ Pane { } onTextChanged: { + // work around Qt issue, TextArea fires spurious textChanged events + // NOTE: might be Qt virtual keyboard, or Qt upgrade from 5.15.2 to 5.15.7 + if (root.text != text) + root.text = text + + // update suggestions _suggestions = bitcoin.mnemonicsFor(seedtextarea.text.split(' ').pop()) // TODO: cursorPosition only on suggestion apply cursorPosition = text.length