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
This commit is contained in:
PavelS 2022-08-18 14:45:38 +03:00 committed by Michał Cieślak
parent f157229e36
commit 2d3e7919f1
2 changed files with 9 additions and 4 deletions

View File

@ -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.

View File

@ -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
}
}