Skip to content

Commit b927305

Browse files
committed
fix(navigation): add equals/hashCode to ModalBottomSheetScene to prevent duplicate sheets
The navigation3 library upgrade from 1.0.1 to 1.1.0 introduced persistent tracking of overlay scenes via a SnapshotStateList. It checks `!currentOverlayScenes.contains(it)` before adding new scenes, which relies on equals(). ModalBottomSheetScene was a plain class with no equals()/hashCode(), so every recalculation created a non-equal instance that was added as a duplicate — causing two sheets to animate up simultaneously when returning from Phantom wallet deeplinks.
1 parent c356380 commit b927305

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

ui/navigation/src/main/kotlin/com/getcode/navigation/scenes/ModalBottomSheetSceneStrategy.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ internal class ModalBottomSheetScene<T : Any> @OptIn(ExperimentalMaterial3Api::c
6767

6868
override val entries: List<NavEntry<T>> = listOf(entry)
6969

70+
override fun equals(other: Any?): Boolean {
71+
if (this === other) return true
72+
if (other !is ModalBottomSheetScene<*>) return false
73+
return key == other.key
74+
}
75+
76+
override fun hashCode(): Int = key.hashCode()
77+
7078
@OptIn(ExperimentalMaterial3Api::class)
7179
override val content: @Composable (() -> Unit) = {
7280
// Scope composition by the scene key + generation counter so that

0 commit comments

Comments
 (0)