Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: selected_index norm in reset_navigation() #634

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/uosc/elements/Menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,8 @@ function Menu:reset_navigation()
self:scroll_to(menu.scroll_y) -- clamps scroll_y to scroll limits
if menu.items and #menu.items > 0 then
-- Normalize existing selected_index always, and force it only in keyboard navigation
if not self.mouse_nav and not menu.selected_index then
local from = clamp(1, menu.selected_index or 1, #menu.items)
self:select_index(itable_find(menu.items, function(item) return item.selectable ~= false end, from), menu)
if not self.mouse_nav then
self:select_by_offset(0)
end
else
self:select_index(nil)
Expand Down Expand Up @@ -584,6 +583,7 @@ function Menu:select_by_offset(offset, menu)
else
menu.selected_index = prev_index or next_index or nil
end
request_render()
end

---@param offset integer
Expand Down