Closed rrchai closed 1 month ago
The lazyLoad is enabled in all search dropdown filters, but I need more time to test the behavior when the search term is applied. I will also try to consolidate the multiple lazyLoad functions for different filters into one generic function to reduce codes.
Currently, when users scroll down the results, it will trigger to query next page results (0...N) with constant page size. The new scrolled results will be appended to the existing results. To avoid duplicated queries, the page number is checked to make sure the same page is only loaded once.
However, when the search term is applied, the pagination of query results are different, which could lead to miss or duplicate results. I am checking ...
When using a BehaviorSubject
to emit objects in RxJS (like debounceTime()
), ensure to create a new object when updating the value emitted by a BehaviorSubject:
private platformSearchQuery: BehaviorSubject<ChallengePlatformSearchQuery> =
new BehaviorSubject<ChallengePlatformSearchQuery>({});
setPlatformSearch(searchQuery: ChallengePlatformSearchQuery) {
this.platformSearchQuery.next(searchQuery); // No
this.platformSearchQuery.next({ ...searchQuery }); // Yes
}
ensure to create a new object when updating the value emitted by a BehaviorSubject:
Why?
Note that using the spread operator results in a shallow copy of the object. For deep copy, I am using cloneDeep
from lodash.
Why?
Note that using the spread operator results in a shallow copy of the object. For deep copy, I am using cloneDeep from lodash.
If I don't copy or force the change on the object as BehaviorSubject
, the debounceTime(400)
will not work as expected. Instead of waiting for 400ms, it will trigger the change as soon as I type something in search bar. I didn't look into the exactly reason, but using the spread operator seem to work on my end. I am open to change to deep copy if that's necessary.
I will try to address two more issues for the search filters before making this pr open:
@rrchai Converting the PR back to draft since I saw that you made new commits. Please turn in back to Ready for review when ready.
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
No data about Duplication
Further exploration is needed about the flickering. The issue will be fixed in another PR.
Changelogs
Preview
The bug #2648 is not fixed in this PR, as I think it needs extra backend support, i.e. filter input data types by its ids, which will be saved for another PRs.