diff --git a/emoji/src/androidMain/kotlin/com/vanniktech/emoji/internal/EmojiSearchDialog.kt b/emoji/src/androidMain/kotlin/com/vanniktech/emoji/internal/EmojiSearchDialog.kt index 6c8df7416d..9f8cc9cbff 100644 --- a/emoji/src/androidMain/kotlin/com/vanniktech/emoji/internal/EmojiSearchDialog.kt +++ b/emoji/src/androidMain/kotlin/com/vanniktech/emoji/internal/EmojiSearchDialog.kt @@ -160,6 +160,8 @@ internal class EmojiAdapter( setHasStableIds(true) } + override fun getItemId(position: Int) = items[position].emoji.hashCode().toLong() + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = EmojiViewHolder(parent) override fun onBindViewHolder(holder: EmojiViewHolder, position: Int) { diff --git a/emoji/src/commonMain/kotlin/com/vanniktech/emoji/search/SearchEmojiManager.kt b/emoji/src/commonMain/kotlin/com/vanniktech/emoji/search/SearchEmojiManager.kt index a2d0f47937..857f4c07ff 100644 --- a/emoji/src/commonMain/kotlin/com/vanniktech/emoji/search/SearchEmojiManager.kt +++ b/emoji/src/commonMain/kotlin/com/vanniktech/emoji/search/SearchEmojiManager.kt @@ -25,7 +25,7 @@ class SearchEmojiManager : SearchEmoji { return when { query.length > 1 -> categories.flatMap { it.emojis.toList() } .mapNotNull { emoji -> - emoji.shortcodes.mapNotNull { shortcode -> + emoji.shortcodes.firstNotNullOfOrNull { shortcode -> val index = shortcode.indexOf(query, ignoreCase = true) if (index >= 0) { @@ -37,7 +37,7 @@ class SearchEmojiManager : SearchEmoji { } else { null } - }.firstOrNull() + } } else -> emptyList() }