Skip to content

Commit

Permalink
fix: scroll parent menus when opening menu by id (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-heinrich committed Nov 9, 2023
1 parent a9c83bb commit 38e68e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/uosc/elements/Menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,13 @@ function Menu:activate_submenu(id)
local submenu = self.by_id[id]
if submenu then
self:activate_menu(submenu)
local menu = self.current
local parent = menu.parent_menu
while parent do
parent.selected_index = itable_index_of(parent.items, menu)
self:scroll_to_index(parent.selected_index, parent)
menu, parent = parent, parent.parent_menu
end
else
msg.error(string.format('Requested submenu id "%s" doesn\'t exist', id))
end
Expand Down

0 comments on commit 38e68e1

Please sign in to comment.