fix(edit): stop cursor jumping in event text fields

The event form's state pipeline ran .flowOn(io) over the whole combine,
including the _form round-trip every keystroke depends on. That async hop
handed BasicTextField a lagging value while typing, so Compose kept
correcting the cursor to the stale position.

Scope flowOn(io) to just the calendar/prefs/settings reads and collect the
form -> state -> UI path on the main dispatcher, so keystrokes round-trip
synchronously and the cursor stays put.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-15 21:16:32 +02:00
parent f990af1cb0
commit 9a1903e6ed
2 changed files with 8 additions and 2 deletions

View File

@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Fixed
- Typing in the event title, location, and description fields no longer
makes the cursor jump around: the form state's round-trip to the UI was
hopping to a background dispatcher, so the text field saw a lagging value
while typing. Only the calendar/preferences reads stay off the main
thread now; the keystroke path is synchronous again
## [2.0.0] — 2026-06-11 ## [2.0.0] — 2026-06-11
### Added ### Added

View File

@@ -109,7 +109,7 @@ class EventEditViewModel @Inject constructor(
prefs.lastUsedCalendarId, prefs.lastUsedCalendarId,
settingsPrefs.defaultFormFields, settingsPrefs.defaultFormFields,
::ExternalInputs, ::ExternalInputs,
), ).flowOn(io),
) { local, external -> ) { local, external ->
val form = local.form ?: return@combine null val form = local.form ?: return@combine null
val resolvedId = form.calendarId val resolvedId = form.calendarId
@@ -131,7 +131,6 @@ class EventEditViewModel @Inject constructor(
resolved.rrule != local.editTarget.original.rrule, resolved.rrule != local.editTarget.original.rrule,
) )
} }
.flowOn(io)
.stateIn( .stateIn(
scope = viewModelScope, scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000L), started = SharingStarted.WhileSubscribed(5_000L),