open-admin icon indicating copy to clipboard operation
open-admin copied to clipboard

$form->belongsToMany list in selection modal is losing its events after page change.

Open bytebrain opened this issue 1 year ago • 1 comments

Describe the bug When the list in the select modal of $form->belongsToMany has paging, after the page is changed, the checkbox events of the list are gone.

To Reproduce Create a $form->belongsToMany() with more than 10 selectable records. Open the select modal, change page, select a record and hit submit. The selected record is not added to the belongsToMany list.

Expected behavior It should add the selected record.

System

  • Open-admin version 1.0.27
  • PHP version 8.2
  • Laravel Version 10
  • OS: Linux / Win / Mac
  • Browser chrome

Solution After some debugging, I found some remarked code in open-admin/resources/assets/open-admin/js/open-admin-selectable.js:

                /*
                // now handeled through admin.ajax.currentTarget
                if (event.target.classList.contains('page-link')){
                    load(event.target.getAttribute("href"));
                    event.preventDefault();
                    event.stopPropagation();
                    return false;
                }
                */

When I unremark it, the selection of records keep working after page change.

bytebrain avatar Aug 02 '23 12:08 bytebrain

@bytebrain thanks for the support!

open-admin-org avatar Nov 08 '23 20:11 open-admin-org