Skip to content

Commit f454de5

Browse files
committed
feat: remove auto-focus from ConsoleSurface
- Remove `requestFocus()` on first composition to avoid layout-related crashes on Android and CI hangs on WasmJs. - Update documentation to reflect that focus is now managed via manual tap gestures on the surface. - Remove unused `withFrameNanos` import.
1 parent 0d24144 commit f454de5

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

  • feature/console/ui/src/commonMain/kotlin/com/softartdev/notedelight/feature/console/ui

feature/console/ui/src/commonMain/kotlin/com/softartdev/notedelight/feature/console/ui/ConsoleSurface.kt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import androidx.compose.material3.Surface
1212
import androidx.compose.runtime.Composable
1313
import androidx.compose.runtime.LaunchedEffect
1414
import androidx.compose.runtime.remember
15-
import androidx.compose.runtime.withFrameNanos
1615
import androidx.compose.ui.Modifier
1716
import androidx.compose.ui.focus.FocusRequester
1817
import androidx.compose.ui.input.pointer.pointerInput
@@ -36,9 +35,11 @@ import com.softartdev.notedelight.feature.console.ui.theme.rememberConsoleTheme
3635
* - Inside, a single scrolling [Column] contains the read-only [ConsoleHistoryCanvas] followed
3736
* directly by the active [ConsoleInputRow]. The two share typography and palette from
3837
* [ConsoleTheme] so visually the input is the last line of the transcript.
39-
* - [FocusRequester] is requested on first composition so the keyboard pops without an extra
40-
* tap. A transparent tap-gesture detector on the surface re-focuses the input when the user
41-
* taps anywhere in the history — a common terminal affordance.
38+
* - A transparent tap-gesture detector on the surface focuses the input when the user taps
39+
* anywhere in the history — a common terminal affordance. Auto-focus on entry is deliberately
40+
* omitted: `requestFocus()` triggers an async `bringIntoView()` that crashes before layout
41+
* completes on Android, and `withFrameNanos` (which would defer it past layout) blocks
42+
* `waitForIdle()` on wasmJs Chrome Headless in CI.
4243
* - [Modifier.imePadding] prevents the Android soft keyboard from hiding the input line.
4344
* - Auto-scroll fires on either (a) the buffer growing (execution appended history) or (b) the
4445
* input gaining/losing a `\n` (continuation line added/removed), keeping the caret visible.
@@ -58,15 +59,6 @@ fun ConsoleSurface(
5859
val focusRequester: FocusRequester = remember { FocusRequester() }
5960
val scrollState = rememberScrollState()
6061

61-
// Auto-focus the input on entry so the keyboard pops without an extra tap.
62-
// Wait one frame so the surrounding layout (verticalScroll Column) is placed before the
63-
// BasicTextField's internal BringIntoViewRequester reacts to focus — otherwise it throws
64-
// "Expected BringIntoViewRequester to not be used before parents are placed."
65-
LaunchedEffect(Unit) {
66-
withFrameNanos { }
67-
runCatching { focusRequester.requestFocus() }
68-
}
69-
7062
// Auto-scroll to the bottom whenever history or multi-line input grows/shrinks.
7163
val inputNewlineCount: Int = inputText.count { it == '\n' }
7264
LaunchedEffect(buffer.lineCount, inputNewlineCount, running) {

0 commit comments

Comments
 (0)