Status Update
Comments
so...@google.com <so...@google.com> #3
We did have that kind of check some time ago
onValueChange = {
val prevValue = fullModel.value.text
fullModel.value = it
if (prevValue != it.text) {
onValueChange(it.text)
}
}
so it doesn't seem unreasonable to trigger the callback only if text/selection changes
si...@google.com <si...@google.com> #4
Thanks Anastasia
I believe it is when TextFieldValue changes (which includes text, selection, composition)
If any of those values changed and onValueChange is fired, it is WAI.
so...@google.com <so...@google.com> #5
Ah, I see, you're right.
BTW I've just quickly checked it and couldn't reproduce the bug.
si...@google.com <si...@google.com>
si...@google.com <si...@google.com>
ap...@google.com <ap...@google.com> #7
Branch: androidx-main
commit a736e803e286bc3326300d68a8af7daaaab2aa76
Author: Siyamed Sinir <siyamed@google.com>
Date: Fri Apr 02 07:31:08 2021
Prevent TextField.onValueChange to fire if no change
- Added TextFieldValue overload to compare previous and
new value
- Replaced string version calling into TextFieldValue
version in order to
a) prevent double string comparison
b) (minor) extra function call
Test: ./gradlew compose:foundation:foundation:test
Test: ./gradlew compose:foundation:foundation:cAT
Bug: 178510628
Change-Id: I961ed03d8d6b7e956e8c87e0cb3539890650c00a
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicTextField.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/TextFieldValue.kt
si...@google.com <si...@google.com>
ap...@google.com <ap...@google.com> #8
Branch: androidx-main
commit 158980e5a32ea39d9d4ef50e69de059023b92456
Author: Siyamed Sinir <siyamed@google.com>
Date: Fri Apr 02 07:37:10 2021
Add tests for BasicTextField.onValueChange
Added tests to check when
- no change occurs in text, String overload does not
call onValueChange
- no change occurs in value, TextFieldValue overload
does not call onValueChange
Test: ./gradlew compose:foundation:foundation:test
Test: ./gradlew compose:foundation:foundation:cAT
RelNote: Added experimental performanTextInputSelection API
Bug: 178510628
Change-Id: I2dcbbbc0178b62c7a290a7e170e00b26b74d7237
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt
M compose/ui/ui-test/api/public_plus_experimental_1.0.0-beta05.txt
M compose/ui/ui-test/api/public_plus_experimental_current.txt
M compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/TextActions.kt
tj...@fieldwire.com <tj...@fieldwire.com> #9
Hi, look like a part of this bug still remains. When the CoreTextField
composable is disposed, onBlur
gets called inside TextFieldDelegate
. A copy of TextFieldValue object is created there editProcessor.toTextFieldValue().copy(composition = null)
When this happens onValueChanged will always get called since it will fail the if check
if (value != it) {
onValueChange(it)
}
I am seeing this on foundation:1.5.0-alpha01. Please fix thanks!
hr...@gmail.com <hr...@gmail.com> #10
I am facing issue where recomposition happens and the state is reset due to onValueChange() that is causing unnecessary and wrongful recomposition.
Description
Click on TextField, lose focus and click again or put app in background and reopen, these focus changes calls the
onValueChange
callback of TextField even with no actual text changes. This is unexpected behaviour andonValueChange
callback should only be called when there's any actual change in the text.