fix(ui): CountersSelector selectedPage calculation
This commit is contained in:
parent
6af0669b99
commit
11831c9054
@ -72,7 +72,7 @@ local function renderCountersMap(countersMap, selectedCounter, titleFn)
|
||||
|
||||
local availableHeight = height - topMargin - bottomMargin
|
||||
|
||||
local selectedPage = (selectedCounter % availableHeight) + 1
|
||||
local selectedPage = math.floor(selectedCounter / availableHeight) + 1
|
||||
-- local totalPages = (nbCounters % availableHeight) + 1
|
||||
|
||||
local nbElementsToOmit = (selectedPage - 1) * availableHeight
|
||||
@ -122,6 +122,8 @@ local function CountersSelector(initialCountersMap, config)
|
||||
|
||||
local shouldContinue = true
|
||||
while shouldContinue do
|
||||
renderCountersMap(countersMap, selectedCounter, titleFn)
|
||||
|
||||
local _, keyPressed, isHeld = os.pullEvent('key')
|
||||
|
||||
if keyPressed == keys.up then
|
||||
@ -143,10 +145,6 @@ local function CountersSelector(initialCountersMap, config)
|
||||
elseif keyPressed == keys.enter then
|
||||
shouldContinue = false
|
||||
end
|
||||
|
||||
if shouldContinue then
|
||||
renderCountersMap(countersMap, selectedCounter, titleFn)
|
||||
end
|
||||
end
|
||||
|
||||
restoreTermConfig()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user