From 5d7d1d6f8bb941936bb2e001a39a0c4d05bd4643 Mon Sep 17 00:00:00 2001
From: Abdelilah El Aissaoui <aeab13@gmail.com>
Date: Sun, 23 Oct 2022 18:05:20 +0200
Subject: [PATCH] Removed use of keys in graph commits list

---
 src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt
index aede952..d23b924 100644
--- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt
+++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/log/Log.kt
@@ -382,7 +382,9 @@ fun MessagesList(
                 )
             }
         }
-        items(items = commitList, key = { it.name }) { graphNode ->
+        // Setting a key makes the graph preserve the scroll position when a new line has been added on top (uncommited changes)
+        // Therefore, after popping a stash, the uncommited changes wouldn't be visible and requires the user scrolling.
+        items(items = commitList) { graphNode ->
             CommitLine(
                 graphWidth = graphWidth,
                 logViewModel = logViewModel,
@@ -485,7 +487,7 @@ fun GraphList(
                     }
                 }
 
-                items(items = commitList, key = { it.name }) { graphNode ->
+                items(items = commitList) { graphNode ->
                     val nodeColor = colors[graphNode.lane.position % colors.size]
 
                     Row(