mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
Fix room list not scrollable in room select screen when the account switch is hidden
The nested scroll connection of the account switch section was always attached. When the section is not displayed (single account, Forward mode, or search active), its height offset limit is never set and stays at -Float.MAX_VALUE, so the connection consumed all the scroll events and the room list could not be scrolled. Only attach the connection when the account switch section is displayed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+8
-1
@@ -177,7 +177,14 @@ fun RoomSelectView(
|
|||||||
Modifier
|
Modifier
|
||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.consumeWindowInsets(paddingValues)
|
.consumeWindowInsets(paddingValues)
|
||||||
.nestedScroll(accountSwitchScrollBehavior.nestedScrollConnection)
|
.then(
|
||||||
|
// Only when the account switch section is displayed, else its unknown height would consume all the scroll events
|
||||||
|
if (state.showAccountSwitch && !state.isSearchActive) {
|
||||||
|
Modifier.nestedScroll(accountSwitchScrollBehavior.nestedScrollConnection)
|
||||||
|
} else {
|
||||||
|
Modifier
|
||||||
|
}
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
SearchBar(
|
SearchBar(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
+39
@@ -13,8 +13,12 @@ import androidx.activity.ComponentActivity
|
|||||||
import androidx.compose.ui.test.AndroidComposeUiTest
|
import androidx.compose.ui.test.AndroidComposeUiTest
|
||||||
import androidx.compose.ui.test.ExperimentalTestApi
|
import androidx.compose.ui.test.ExperimentalTestApi
|
||||||
import androidx.compose.ui.test.assertIsDisplayed
|
import androidx.compose.ui.test.assertIsDisplayed
|
||||||
|
import androidx.compose.ui.test.assertIsNotDisplayed
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
|
import androidx.compose.ui.test.onRoot
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
|
import androidx.compose.ui.test.performTouchInput
|
||||||
|
import androidx.compose.ui.test.swipeUp
|
||||||
import androidx.compose.ui.test.v2.runAndroidComposeUiTest
|
import androidx.compose.ui.test.v2.runAndroidComposeUiTest
|
||||||
import io.element.android.libraries.designsystem.theme.components.SearchBarResultState
|
import io.element.android.libraries.designsystem.theme.components.SearchBarResultState
|
||||||
import io.element.android.libraries.matrix.api.core.RoomId
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
@@ -29,6 +33,7 @@ import io.element.android.tests.testutils.EventsRecorder
|
|||||||
import io.element.android.tests.testutils.clickOn
|
import io.element.android.tests.testutils.clickOn
|
||||||
import io.element.android.tests.testutils.robolectric.RobolectricTest
|
import io.element.android.tests.testutils.robolectric.RobolectricTest
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
|
||||||
@@ -123,6 +128,33 @@ class RoomSelectViewTest : RobolectricTest() {
|
|||||||
onNodeWithText(activity!!.getString(CommonStrings.common_switch_account)).assertDoesNotExist()
|
onNodeWithText(activity!!.getString(CommonStrings.common_switch_account)).assertDoesNotExist()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `the room list can be scrolled when there is no other account`() = runAndroidComposeUiTest {
|
||||||
|
setRoomSelectView(
|
||||||
|
aRoomSelectState(
|
||||||
|
mode = RoomSelectMode.Share,
|
||||||
|
resultState = SearchBarResultState.Results(aLongRoomList()),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
onNodeWithText("Room 0").assertIsDisplayed()
|
||||||
|
onRoot().performTouchInput { swipeUp() }
|
||||||
|
onNodeWithText("Room 0").assertIsNotDisplayed()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `the room list can be scrolled when there are other accounts`() = runAndroidComposeUiTest {
|
||||||
|
setRoomSelectView(
|
||||||
|
aRoomSelectState(
|
||||||
|
mode = RoomSelectMode.Share,
|
||||||
|
resultState = SearchBarResultState.Results(aLongRoomList()),
|
||||||
|
otherAccounts = persistentListOf(aMatrixUser(id = "@bob:example.org", displayName = "Bob")),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
onNodeWithText("Room 0").assertIsDisplayed()
|
||||||
|
onRoot().performTouchInput { swipeUp() }
|
||||||
|
onNodeWithText("Room 0").assertIsNotDisplayed()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `an error is displayed instead of the rooms if they cannot be loaded`() = runAndroidComposeUiTest<ComponentActivity> {
|
fun `an error is displayed instead of the rooms if they cannot be loaded`() = runAndroidComposeUiTest<ComponentActivity> {
|
||||||
setRoomSelectView(
|
setRoomSelectView(
|
||||||
@@ -150,3 +182,10 @@ private fun AndroidComposeUiTest<ComponentActivity>.setRoomSelectView(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun aLongRoomList() = List(30) { index ->
|
||||||
|
aSelectRoomInfo(
|
||||||
|
roomId = RoomId("!room$index:domain"),
|
||||||
|
name = "Room $index",
|
||||||
|
)
|
||||||
|
}.toImmutableList()
|
||||||
|
|||||||
Reference in New Issue
Block a user