Skip to content

Commit

Permalink
Update pagintion after changing sections when resetting the filter
Browse files Browse the repository at this point in the history
Fixes #251
  • Loading branch information
meowgorithm committed Mar 2, 2021
1 parent 851d21f commit 3a57221
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ui/stash.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,21 @@ func (m *stashModel) resetFiltering() {
m.bakeConvertedDocs()

sort.Stable(markdownsByLocalFirst(m.markdowns))
m.updatePagination()

// If the filtered section is present (it's always at the end) slice it out
// of the sections slice to remove it from the UI.
if m.sections[len(m.sections)-1].key == filterSection {
m.sections = m.sections[:len(m.sections)-1]
}

// If the current section is out of bounds (it would be if we cut down the
// slice above) then return to the first section.
if m.sectionIndex > len(m.sections)-1 {
m.sectionIndex = 0
}

// Update pagination after we've switched sections.
m.updatePagination()
}

// Is a filter currently being applied?
Expand Down

0 comments on commit 3a57221

Please sign in to comment.