Skip to content

Commit

Permalink
Updated function loadMoreData to get all the collections to populate …
Browse files Browse the repository at this point in the history
…them in the Collection dropdown list.

Deleted the  dropdownSelect.addEventListener('scroll' .... as the <select> tag does not support the scroll event
  • Loading branch information
TyroneAEM committed Feb 23, 2024
1 parent de461a6 commit 2046580
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ async function createDropdown(addToExistingRadioDropboxContainer) {
dropdownSelect.classList.add('add-to-existing-dropdown'); // Add the new class

// Function to load more data when reaching the end of the dropdown
//const loadMoreData = async (cursor) => {
const loadMoreData = async (page) => {
const collectionData = await searchListCollection(100, page);
//Call to get the nbHits for the total number of Collections

Check failure on line 47 in blocks/adp-add-to-collection-modal/adp-add-to-collection-modal.js

View workflow job for this annotation

GitHub Actions / build

Expected exception block, space or tab after '//' in comment
let collectionMax = await searchListCollection(0,0);

Check failure on line 48 in blocks/adp-add-to-collection-modal/adp-add-to-collection-modal.js

View workflow job for this annotation

GitHub Actions / build

'collectionMax' is never reassigned. Use 'const' instead

Check failure on line 48 in blocks/adp-add-to-collection-modal/adp-add-to-collection-modal.js

View workflow job for this annotation

GitHub Actions / build

A space is required after ','
const collectionData = await searchListCollection(collectionMax.nbHits,page);

Check failure on line 49 in blocks/adp-add-to-collection-modal/adp-add-to-collection-modal.js

View workflow job for this annotation

GitHub Actions / build

A space is required after ','
return collectionData;
};

let page = 0;

// Event listener to detect scroll and load more data when at the bottom
/* The scroll event is commented out, since the <select> does not support it
dropdownSelect.addEventListener('scroll', async () => {
if (dropdownSelect.scrollTop + dropdownSelect.clientHeight >= dropdownSelect.scrollHeight) {
const moreData = await loadMoreData(page);
Expand All @@ -68,12 +69,12 @@ async function createDropdown(addToExistingRadioDropboxContainer) {
}
}
});
*/

const page = 0;
// Initial data loading
const initialData = await loadMoreData(page);
if (initialData.items.length > 0) {

Check failure on line 77 in blocks/adp-add-to-collection-modal/adp-add-to-collection-modal.js

View workflow job for this annotation

GitHub Actions / build

Block must not be padded by blank lines
//Update page to next load
page++;

// Populate the options in the dropdown with the initial data
initialData.items.forEach((collection) => {
Expand Down

0 comments on commit 2046580

Please sign in to comment.