Skip to content

Commit f007a25

Browse files
author
Zahraa Chreim
committed
132284: Reset pagination button state when navigating away from the subject category page
(cherry picked from commit 231da9c)
1 parent eb476ad commit f007a25

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

src/app/shared/form/vocabulary-treeview/vocabulary-treeview.component.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,9 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges
169169

170170
readonly AlertType = AlertType;
171171

172-
public showNextPage$ = this.vocabularyTreeviewService.showNextPageSubject
173-
? this.vocabularyTreeviewService.showNextPageSubject.asObservable()
174-
: of(false);
172+
public showNextPage$: Observable<boolean>;
175173

176-
public showPreviousPage$ = this.vocabularyTreeviewService.showPreviousPageSubject
177-
? this.vocabularyTreeviewService.showPreviousPageSubject.asObservable()
178-
: of(false);
174+
public showPreviousPage$: Observable<boolean>;
179175

180176
/**
181177
* Initialize instance variables
@@ -279,6 +275,12 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges
279275
* Initialize the component, setting up the data to build the tree
280276
*/
281277
ngOnInit(): void {
278+
279+
// Initialize observables to false when component loads
280+
// Ensures pagination buttons are hidden on first load or after navigation
281+
this.showNextPage$ = of(false);
282+
this.showPreviousPage$ = of(false);
283+
282284
this.subs.push(
283285
this.vocabularyService.findVocabularyById(this.vocabularyOptions.name).pipe(
284286
// Retrieve the configured preloadLevel from REST
@@ -348,6 +350,17 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges
348350
* Search for a vocabulary entry by query
349351
*/
350352
search() {
353+
354+
// Reassign observables after performing each new search
355+
// Updates pagination button visibility based on available pages
356+
this.showNextPage$ = this.vocabularyTreeviewService.showNextPageSubject
357+
? this.vocabularyTreeviewService.showNextPageSubject.asObservable()
358+
: of(false);
359+
360+
this.showPreviousPage$ = this.vocabularyTreeviewService.showPreviousPageSubject
361+
? this.vocabularyTreeviewService.showPreviousPageSubject.asObservable()
362+
: of(false);
363+
351364
if (isNotEmpty(this.searchText)) {
352365
if (isEmpty(this.storedNodeMap)) {
353366
this.storedNodeMap = this.nodeMap;

0 commit comments

Comments
 (0)