Skip to content

Commit f980f38

Browse files
committed
load more fix
1 parent dc62799 commit f980f38

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

frontend/src/components/pages/search/SearchPage.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
height: 40px;
4444
}
4545

46+
.search-page-load-more-button {
47+
background-color: var(--button-primary-color);
48+
color: var(--background-color-dark-heavy);
49+
--bs-btn-hover-bg: var(--accent-bright);
50+
border: 1px solid var(--additional-gray);
51+
border-radius: 10px;
52+
height: 40px;
53+
}
54+
4655
.search-page-reset-button {
4756
transition: 0.4s;
4857
background-color: var(--button-secondary-color);

frontend/src/components/pages/search/SearchPage.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ const SearchPage = ({ apiPrefix }) => {
104104
}
105105
};
106106

107+
const handleLoadMore = () => {
108+
const currentScrollY = window.scrollY;
109+
110+
setCurrentPage((prevPage) => prevPage + 1);
111+
112+
setTimeout(() => {
113+
window.scrollTo(0, currentScrollY);
114+
}, 100);
115+
};
116+
107117
const applyInputFilters = () => {
108118
setFilters((prevFilters) => ({
109119
...prevFilters,
@@ -485,9 +495,9 @@ const SearchPage = ({ apiPrefix }) => {
485495
{hasMore && (
486496
<div className="text-center">
487497
<button
488-
onClick={() => setCurrentPage((prev) => prev + 1)}
489-
className="btn btn-primary my-3"
490-
disabled={isLoading}
498+
onClick={handleLoadMore}
499+
disabled={isLoading || !hasMore}
500+
className="btn search-page-load-more-button my-3"
491501
>
492502
{isLoading ? 'Loading...' : 'Load More'}
493503
</button>

0 commit comments

Comments
 (0)