From 8e66494ec279c9f02d4dd6c672c49212807b826a Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Mon, 20 Jul 2020 20:58:39 +0200 Subject: [PATCH] [fix] Use orderedPairs in touch menu item table (#6404) Cf. and . --- frontend/ui/widget/menu.lua | 3 ++- spec/unit/widget_menu_spec.lua | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/ui/widget/menu.lua b/frontend/ui/widget/menu.lua index 9ffb8379d..51329f0bb 100644 --- a/frontend/ui/widget/menu.lua +++ b/frontend/ui/widget/menu.lua @@ -8,6 +8,7 @@ local BottomContainer = require("ui/widget/container/bottomcontainer") local Button = require("ui/widget/button") local CenterContainer = require("ui/widget/container/centercontainer") local Device = require("device") +local FFIUtil = require("ffi/util") local FocusManager = require("ui/widget/focusmanager") local Font = require("ui/font") local FrameContainer = require("ui/widget/container/framecontainer") @@ -1326,7 +1327,7 @@ end function Menu.itemTableFromTouchMenu(t) local item_t = {} - for k,v in pairs(t) do + for k, v in FFIUtil.orderedPairs(t) do local item = { text = k } if v.callback then item.callback = v.callback diff --git a/spec/unit/widget_menu_spec.lua b/spec/unit/widget_menu_spec.lua index 590cf1d48..8c2722378 100644 --- a/spec/unit/widget_menu_spec.lua +++ b/spec/unit/widget_menu_spec.lua @@ -20,7 +20,11 @@ describe("Menu widget", function() }, }) --- @fixme: Currently broken because pairs (c.f., https://github.com/koreader/koreader/pull/6371#issuecomment-657251302) - assert.are.same(re, { + assert.are.same({ + { + text = 'exit', + callback = cb2, + }, { text = 'navi', sub_item_table = { @@ -29,10 +33,6 @@ describe("Menu widget", function() { text = 'bar', callback = cb2 }, } }, - { - text = 'exit', - callback = cb2, - } - }) + }, re) end) end)