Added focus restoration when closing commit changes search
This commit is contained in:
parent
e38746cd0e
commit
0f5e4248b9
@ -33,6 +33,7 @@ import com.jetpackduba.gitnuro.ui.tree_files.TreeItem
|
|||||||
import com.jetpackduba.gitnuro.viewmodels.CommitChangesStateUi
|
import com.jetpackduba.gitnuro.viewmodels.CommitChangesStateUi
|
||||||
import com.jetpackduba.gitnuro.viewmodels.CommitChangesViewModel
|
import com.jetpackduba.gitnuro.viewmodels.CommitChangesViewModel
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.eclipse.jgit.diff.DiffEntry
|
import org.eclipse.jgit.diff.DiffEntry
|
||||||
import org.eclipse.jgit.lib.PersonIdent
|
import org.eclipse.jgit.lib.PersonIdent
|
||||||
@ -47,10 +48,20 @@ fun CommitChanges(
|
|||||||
onBlame: (String) -> Unit,
|
onBlame: (String) -> Unit,
|
||||||
onHistory: (String) -> Unit,
|
onHistory: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
val tabFocusRequester = LocalTabFocusRequester.current
|
||||||
|
|
||||||
LaunchedEffect(selectedItem) {
|
LaunchedEffect(selectedItem) {
|
||||||
commitChangesViewModel.loadChanges(selectedItem.revCommit)
|
commitChangesViewModel.loadChanges(selectedItem.revCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(commitChangesViewModel) {
|
||||||
|
commitChangesViewModel.showSearch.collectLatest { show ->
|
||||||
|
if (!show) {
|
||||||
|
tabFocusRequester.requestFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val commitChangesStatus = commitChangesViewModel.commitChangesStateUi.collectAsState().value
|
val commitChangesStatus = commitChangesViewModel.commitChangesStateUi.collectAsState().value
|
||||||
val showSearch by commitChangesViewModel.showSearch.collectAsState()
|
val showSearch by commitChangesViewModel.showSearch.collectAsState()
|
||||||
val changesListScroll by commitChangesViewModel.changesLazyListState.collectAsState()
|
val changesListScroll by commitChangesViewModel.changesLazyListState.collectAsState()
|
||||||
|
Loading…
Reference in New Issue
Block a user