Skip to content

Commit d6d554c

Browse files
authored
Fix off-by-one issue where right arrow wasn't displaying if the last page had only 1 topic. (#68)
1 parent b66ce55 commit d6d554c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

javascripts/discourse/components/featured-homepage-topics.gjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default class FeaturedHomepageTopics extends Component {
180180
get showRightArrow() {
181181
return (
182182
this.currentFeaturedTopic <
183-
this.featuredTopicsAvailable - this.actualTopicsDisplayed - 1
183+
this.featuredTopicsAvailable - this.actualTopicsDisplayed
184184
);
185185
}
186186

spec/system/pagination_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,25 @@
8787
expect(page).to have_css(".featured-topics-controls .right-page-button")
8888
expect(page).to have_css(".featured-topics-controls .left-page-button")
8989
end
90+
91+
it "should allow pagination even if last page only has 1 topic" do
92+
theme.update_setting(:number_of_topics, 3)
93+
theme.update_setting(:max_number_of_topics, 4)
94+
theme.save!
95+
96+
# First page should have a right arrow when there's only 1 topic on the next page
97+
visit("/")
98+
expect(page).to have_css(".featured-topics .featured-topic", count: 3)
99+
expect(page).to have_css(".featured-topics-controls .page-button-container")
100+
expect(page).to have_css(".featured-topics-controls .right-page-button")
101+
expect(page).not_to have_css(".featured-topics-controls .left-page-button")
102+
103+
# Last page should only have left arrow
104+
find(".featured-topics-controls .right-page-button").click
105+
expect(page).to have_css(".featured-topics .featured-topic", count: 1)
106+
expect(page).to have_css(".featured-topics-controls .page-button-container")
107+
expect(page).not_to have_css(".featured-topics-controls .right-page-button")
108+
expect(page).to have_css(".featured-topics-controls .left-page-button")
109+
end
90110
end
91111
end

0 commit comments

Comments
 (0)