diff --git a/.changeset/upset-rules-smash.md b/.changeset/upset-rules-smash.md new file mode 100644 index 000000000..cdfad2f5c --- /dev/null +++ b/.changeset/upset-rules-smash.md @@ -0,0 +1,5 @@ +--- +'@finsweet/attributes-list': patch +--- + +fix: pagination buttons not working when instance is added to the list instead of the wrapper element diff --git a/packages/list/src/load/pagination.ts b/packages/list/src/load/pagination.ts index 935be5248..72b70a230 100644 --- a/packages/list/src/load/pagination.ts +++ b/packages/list/src/load/pagination.ts @@ -348,12 +348,15 @@ const handlePaginationButtons = (list: List) => { if (!isElement(target)) return; + const listWrapperElement = target.closest(getCMSElementSelector('wrapper')); const nextButton = target.closest(getCMSElementSelector('pagination-next')); const previousButton = target.closest(getCMSElementSelector('pagination-previous')); const button = nextButton || previousButton; + if (!button) return; - if (!button || getInstance(button) !== list.instance) return; + const isSameInstance = list.wrapperElement === listWrapperElement || getInstance(button) === list.instance; + if (!isSameInstance) return; e.preventDefault();