From b865fa6eddd8fad4b340106df48d1a03daf7dd8c Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Wed, 23 Sep 2026 15:42:55 +0000 Subject: [PATCH] android: show attachment options above the keyboard --- .../simplex/common/views/chat/ChatView.kt | 2 +- ...-23-fix-attachment-sheet-under-keyboard.md | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 plans/2026-09-23-fix-attachment-sheet-under-keyboard.md diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt index 7e43db2e98..c1998ee1fd 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt @@ -143,7 +143,7 @@ fun ChatView( ) } val attachmentOption = rememberSaveable { mutableStateOf(null) } - val attachmentBottomSheetState = rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden) + val attachmentBottomSheetState = rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden, skipHalfExpanded = true) val scope = rememberCoroutineScope() val selectedChatItems = rememberSaveable { mutableStateOf(null as Set?) } val showCommandsMenu = rememberSaveable { mutableStateOf(false) } diff --git a/plans/2026-09-23-fix-attachment-sheet-under-keyboard.md b/plans/2026-09-23-fix-attachment-sheet-under-keyboard.md new file mode 100644 index 0000000000..672e59aed5 --- /dev/null +++ b/plans/2026-09-23-fix-attachment-sheet-under-keyboard.md @@ -0,0 +1,60 @@ +# Fix attachment options hidden under the keyboard + +## Problem + +On Android, when the keyboard is already open and the user taps the attachment +(paperclip) button in a chat, the sheet with the Camera / Image / Video / File +options opens partly or fully under the keyboard. With the keyboard closed it opens +correctly. + +## Cause + +The sheet is a Material `ModalBottomSheetLayout` (`ChatView.kt`, `ChatLayout`) whose +state is created in `ChatView` as +`rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden)`, leaving +`skipHalfExpanded` at its default `false`. + +The sheet content, `ChooseAttachmentView`, pads itself with +`.navigationBarsPadding().imePadding()`, so while the keyboard is open the sheet's +height is the buttons row plus the keyboard height, and the buttons are at the top of +the sheet. + +In Material 1.8.2 (`androidx.compose.material:material`, `ModalBottomSheet.kt`): + +- `modalBottomSheetAnchors` adds a `HalfExpanded` anchor at `fullHeight / 2` whenever + `!isSkipHalfExpanded && sheetSize.height > fullHeight / 2`; +- `show()` animates a hidden sheet to `HalfExpanded` when that anchor exists, and to + `Expanded` otherwise. + +With the keyboard closed the sheet is short, there is no `HalfExpanded` anchor, and +it opens `Expanded`. With the keyboard open the sheet is taller than half the +layout, so it stops at `HalfExpanded`: its top is at the middle of the screen, and +the buttons row below it lands under the keyboard's top edge. + +## Fix + +Pass `skipHalfExpanded = true` to the attachment sheet's +`rememberModalBottomSheetState`. `show()` then always goes to `Expanded`, so the +sheet's bottom sits at the bottom of the layout and the `imePadding` places the +buttons directly above the keyboard. + +The half-expanded state has no use for this sheet: it holds a single row of buttons +and no scrollable content. + +## Scope / non-goals + +- Only the chat attachment sheet is changed. The other `ModalBottomSheetLayout`s + (`GroupProfileView`, `UserProfileView`, `AddGroupView`, `AddChannelView`, + `WelcomeView`) use the same default state but are not part of this report. +- The two preview usages of `rememberModalBottomSheetState` in `ChatView.kt` are + left as they are. +- Desktop: the attachment sheet is shared code, but desktop has no software + keyboard inset, so the sheet is never taller than half the window and behaviour + is unchanged. +- iOS was not checked; it does not use this code. + +## Verification + +Debug arm64 APK built from this branch; on a device, open the keyboard in a chat +and tap the attachment button: the options are shown directly above the keyboard. +With the keyboard closed the sheet opens as before.