Skip to content

Conversation

@ahmed-bhs
Copy link
Contributor

@ahmed-bhs ahmed-bhs commented Nov 21, 2025

Q A
Bug fix? no
New feature? yes
BC breaks? no
Fixed tickets #59
License MIT

Summary

This PR adds traditional pagination to both EasyAdmin and Sonata Admin bridges, addressing performance issues when browsing large media libraries. Previously, all media items
were loaded at once, causing slow page loads and high memory usage with libraries containing hundreds or thousands of files.

This implementation uses native pagination components from each framework to ensure a consistent UX that follows admin interface conventions.

Changes

EasyAdmin Bridge:

  • Add MediaPaginator adapter compatible with EasyAdmin's pagination system
  • Use native @EasyAdmin/crud/paginator.html.twig template
  • Remove infinite scroll feature (not standard in admin interfaces)

Sonata Admin Bridge:

  • Add MediaPager implementing Sonata's PagerInterface
  • Create pagination templates based on Sonata's native components
  • Server-side pagination with configurable items per page

Common:

  • Configuration option pagination.per_page (default: 50)
  • Improved performance for large libraries (hundreds/thousands of files)
  • Consistent pagination UX across both admin frameworks

Configuration Example

joli_media_easy_admin:
    pagination:
        per_page: 50  # Number of items per page

joli_media_sonata_admin:
    pagination:
        per_page: 50  # Number of items per page

- Add server-side pagination to OriginalStorage
- Add Config options for per_page and infinite_scroll
- Implement infinite scroll with Intersection Observer
- Add lazy loading for images
- Update MediaAdminController for paginated listings
- Add comprehensive test coverage
@ahmed-bhs ahmed-bhs force-pushed the feature/provide-pagination-infinite-scroll branch from 446bd52 to 7d4bb38 Compare November 21, 2025 20:48
@xavierlacot
Copy link
Member

Hi @ahmed-bhs

Thanks a lot for this first contribution that relates to #52 👍

While I appreciate it a lot, may I ask for some changes?

  • first, the quality tools have to be executed, so the tests turn green. You can use the castor qa:all command to check for errors.
  • second, I am not sure that infinite pagination is a good UX pattern in the admin bridges. Neither EayAdmin nor Sonata Admin natively implement infinite pagination. May I ask you to remove the infinite pagination feature (and the assiociated js code) and instead use a traditional pagination, possibily using the native EasyAdmin pagnination component, to ensure a coherent UX? I am a but annoyed to request the removal of some code that must have taken you time to write, but I think it is the best way to go. Maybe should we explain in the contribution guidelines that is is a good idea to request for advice prior to submitting a UX change pull request?
  • third, the bundle aims to offer comparable levels of functionality between EasyAdmin and Sonata Admin. May I ask to add identical features in the Sonata Admin integration? You can use the demo application to test - see https://mediabundle.jolicode.com/getting-started/demo/#using-the-demo-application-to-contribute-to-jolicode-mediabundle

Thanks again!

- Add trailing comma to function parameters
- Reorder imports alphabetically
- Move private methods to end of class
- Remove unused imports
@ahmed-bhs ahmed-bhs changed the title Add pagination and infinite scroll support to EasyAdmin Add traditional pagination to both admin bridges Nov 23, 2025
@ahmed-bhs ahmed-bhs force-pushed the feature/provide-pagination-infinite-scroll branch 2 times, most recently from f80dc0a to 479685c Compare November 23, 2025 12:10
- Add Media type hints to array properties and parameters
- Fix missing iterable value type specifications
- Ensures PHPStan level compliance
@ahmed-bhs ahmed-bhs force-pushed the feature/provide-pagination-infinite-scroll branch from 6e1b23f to 348adcc Compare November 23, 2025 16:55
@ahmed-bhs
Copy link
Contributor Author

ahmed-bhs commented Nov 23, 2025

Hi @xavierlacot , nice to meet you and thanks for taking the time to review!

I originally developed this feature for my own needs and thought it would be nice to share it as a pull request rather than keep it private. Don't worry at all about the code removal. I completely understand your point about maintaining UX consistency with the native admin frameworks. It makes total sense!

All requested changes are done. Still unsure about using EasyAdmin and Sonata’s native pagination—this part need to be reviewed.

@ahmed-bhs ahmed-bhs force-pushed the feature/provide-pagination-infinite-scroll branch from f64b084 to dcd1e91 Compare November 23, 2025 19:05
default => 'explore',
};

$page = max(1, (int) $request->query->get('page', '1'));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

->getInt() could be used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @BriceFab tank you

@ahmed-bhs ahmed-bhs force-pushed the feature/provide-pagination-infinite-scroll branch from 5458f6f to 3520642 Compare November 26, 2025 15:09
@ahmed-bhs ahmed-bhs force-pushed the feature/provide-pagination-infinite-scroll branch from 3520642 to 9d92777 Compare November 30, 2025 19:47
@ahmed-bhs ahmed-bhs requested a review from BriceFab November 30, 2025 19:47
@xavierlacot xavierlacot merged commit 7a440e3 into jolicode:main Dec 1, 2025
@xavierlacot
Copy link
Member

Thanks for the hard work @ahmed-bhs 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants