From 9f6f9905e988bb98689a4157dc7ad1fd42ea88c2 Mon Sep 17 00:00:00 2001 From: PavelS Date: Thu, 18 Aug 2022 14:45:38 +0300 Subject: [PATCH] fix(StatusInput)!: trigger errors bindings (#858) Change valid to false by default Fixes https://github.com/status-im/status-desktop/issues/6825 BREAKING CHANGE: StatusInput now emits signal for errors change and is invalid by default --- src/StatusQ/Controls/StatusBaseInput.qml | 4 ++-- src/StatusQ/Controls/StatusInput.qml | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/StatusQ/Controls/StatusBaseInput.qml b/src/StatusQ/Controls/StatusBaseInput.qml index cdd2e765..246b1a10 100644 --- a/src/StatusQ/Controls/StatusBaseInput.qml +++ b/src/StatusQ/Controls/StatusBaseInput.qml @@ -182,9 +182,9 @@ Item { /*! \qmlproperty bool StatusBaseInput::valid - This property sets the valid state. Default value is true. + This property sets the valid state. Default value is false. */ - property bool valid: true + property bool valid: false /*! \qmlproperty bool StatusBaseInput::pristine This property sets the pristine. Default value is true. diff --git a/src/StatusQ/Controls/StatusInput.qml b/src/StatusQ/Controls/StatusInput.qml index c763d26b..a6fa4d5f 100644 --- a/src/StatusQ/Controls/StatusInput.qml +++ b/src/StatusQ/Controls/StatusInput.qml @@ -48,6 +48,7 @@ Item { This property holds a reference to the TextEdit's valid property. */ property alias valid: statusBaseInput.valid + /*! \qmlproperty alias StatusInput::pending This property holds a reference to the TextEdit's pending property. @@ -243,7 +244,7 @@ Item { This function resets the text input validation and text. */ function reset() { - statusBaseInput.valid = true + statusBaseInput.valid = false statusBaseInput.pristine = true statusBaseInput.text = "" root.errorMessage = "" @@ -276,8 +277,12 @@ Item { valid: result } } - result.errorMessage = validator.errorMessage errors[validator.name] = result + + // the only way to trigger bindings for var property + errors = errors + result.errorMessage = validator.errorMessage + statusBaseInput.valid = statusBaseInput.valid && false } }