fix(mailbox): anchor account-switcher dropdown to its trigger

The TextButton trigger and its DropdownMenu in AccountSwitcher were
siblings in the drawer's outer Column, so the dropdown's Popup anchored
to the whole Column instead of the button. Wrap both in a shared Box,
the standard Compose pattern, so the menu opens directly below the
account switcher regardless of drawer scroll position or folder count.

Closes #147

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 16:38:32 -05:00
co-authored by Claude Opus 4.8
parent f535561f64
commit 02bfd90c40
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
package org.libremail.ui.mailbox
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
@@ -126,32 +127,34 @@ private fun AccountSwitcher(
onSelect: (String) -> Unit,
) {
var expanded by remember { mutableStateOf(false) }
TextButton(
onClick = { expanded = true },
modifier = Modifier.padding(horizontal = 16.dp),
) {
Text(
current.email,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontWeight = if (current.id in accountsWithUnread) FontWeight.Bold else FontWeight.Normal,
)
Icon(Icons.Filled.ArrowDropDown, contentDescription = stringResource(R.string.drawer_switch_account))
}
DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {
accounts.forEach { account ->
DropdownMenuItem(
text = {
Text(
account.email,
fontWeight = if (account.id in accountsWithUnread) FontWeight.Bold else FontWeight.Normal,
)
},
onClick = {
onSelect(account.id)
expanded = false
},
Box {
TextButton(
onClick = { expanded = true },
modifier = Modifier.padding(horizontal = 16.dp),
) {
Text(
current.email,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontWeight = if (current.id in accountsWithUnread) FontWeight.Bold else FontWeight.Normal,
)
Icon(Icons.Filled.ArrowDropDown, contentDescription = stringResource(R.string.drawer_switch_account))
}
DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {
accounts.forEach { account ->
DropdownMenuItem(
text = {
Text(
account.email,
fontWeight = if (account.id in accountsWithUnread) FontWeight.Bold else FontWeight.Normal,
)
},
onClick = {
onSelect(account.id)
expanded = false
},
)
}
}
}
}