Verified
Status Update
Comments
gu...@google.com <gu...@google.com> #2
Hi. Thanks for reporting this. Fixed in alpha-04
st...@google.com <st...@google.com>
st...@google.com <st...@google.com>
st...@google.com <st...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit e782987543a9f8ccd485e970ddc74564b24378db
Author: Vighnesh Raut <vighnesh.raut13@gmail.com>
Date: Mon Jan 02 15:27:40 2023
fix: tab row crashes when only 1 tab is added
Bug: b/264018028
Test: Added unit test
Change-Id: I6381dbac304fc1d69d3708c6655f8b595668e93f
M tv/tv-material/src/androidTest/java/androidx/tv/material/TabRowTest.kt
M tv/tv-material/src/main/java/androidx/tv/material/TabRow.kt
https://android-review.googlesource.com/2373449
Branch: androidx-main
commit e782987543a9f8ccd485e970ddc74564b24378db
Author: Vighnesh Raut <vighnesh.raut13@gmail.com>
Date: Mon Jan 02 15:27:40 2023
fix: tab row crashes when only 1 tab is added
Bug:
Test: Added unit test
Change-Id: I6381dbac304fc1d69d3708c6655f8b595668e93f
M tv/tv-material/src/androidTest/java/androidx/tv/material/TabRowTest.kt
M tv/tv-material/src/main/java/androidx/tv/material/TabRow.kt
ro...@google.com <ro...@google.com>
na...@google.com <na...@google.com> #4
deleted
na...@google.com <na...@google.com> #5
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.tv:tv-material:1.0.0-alpha04
Description
Function
rememberPickerState
is returning same instance ofPickerState
after recomposition, even when the input has changed.It looks like the issue is because line .
rememberPickerState
is not passing its parameters (initialNumberOfOptions
,initiallySelectedOption
andrepeatItems
) torememberSaveable
function in thisComponent used: rememberPickerState
Version used: 1.0.2
Devices/Android versions reproduced on: N/A
If this is a bug in the library, we would appreciate if you could attach:
I've added unit tests in this commit showing the issue and a proposed solution:https://github.com/luizgrp/horologist/blob/2be07856616edd7a3f833b96b706339897da10ab/sample/src/androidTest/java/androidx/wear/compose/material/PickerTest.kt
testOriginalFunction
test shows that after changing the value ofviewModel. _selectedOption
,MyComposable
does NOT show the new value.testFunctionWithFix
shows that after changing the value ofviewModel. _selectedOption
,MyComposableFixed
shows the new value.rememberPickerStateFixed
is the proposed fix for this issue.This issue was reported by a Googler while using Horologist's TimePicker. The value displayed on the TimePicker is not changing after the values are changed in the ViewModel. To demonstrate that on a simple screen, please see the video attached.
A simple composable displays the hash code value of two
PickerState
objects when the input value is changed, after recomposition. The first line uses the currentrememberPickerState
and the hash code does not change. The second line usesrememberPickerStateFixed
and the hash code changes.