mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
IJPL-165526 Navigation bar: prevent IOOBE while opening the item from navbar popup
(cherry picked from commit 90445b13bc466d1a5b3588a0985ddbb425d3eba3) IJ-CR-148473 GitOrigin-RevId: f50b6d076ce2ec568e6f9157a7c909c42c8f6aa6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fd4b3bcb44
commit
45060649fc
@@ -102,7 +102,15 @@ class NavBarVmImpl(
|
||||
private suspend fun handleSelectionChange() {
|
||||
_items.collectLatest { items: List<NavBarItemVmImpl> ->
|
||||
_selectedIndex.zipWithNext { unselected, selected ->
|
||||
if (unselected >= 0) {
|
||||
|
||||
// Sometimes _selectedIndex may come here before the new _items value even if the _items value was set before _selectedIndex value.
|
||||
// This check prevents OutOfBounds exception.
|
||||
// The _selectedIndex will be replayed here again as soon as the new _items value is collected.
|
||||
if (selected >= items.size) {
|
||||
return@zipWithNext
|
||||
}
|
||||
|
||||
if (unselected >= 0 && unselected < items.size) {
|
||||
items[unselected].selected.value = false
|
||||
}
|
||||
if (selected >= 0) {
|
||||
|
||||
Reference in New Issue
Block a user