Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.12 GridField relation editor JavaScript error #1427

Closed
liefra opened this issue Dec 26, 2022 · 9 comments
Closed

1.12 GridField relation editor JavaScript error #1427

liefra opened this issue Dec 26, 2022 · 9 comments

Comments

@liefra
Copy link

liefra commented Dec 26, 2022

Affected Version

phpunit/phpunit            9.5.27 The PHP Unit Testing framework.
silverstripe-themes/simple 3.2.1  The SilverStripe simple theme (default SilverStripe 3 theme)
silverstripe/login-forms   4.8.0  A collection of templates for the CMS login screens
silverstripe/recipe-cms    4.12.0 SilverStripe recipe for fully featured page and asset content editing
silverstripe/recipe-plugin 1.7.0  Helper plugin to install SilverStripe recipes

Description

When using a GridFieldConfig_RelationEditor in combination with a GridField there is a JavaScript error when the relationship search and link field in the CMS.

The search request itself gets executed correctly and there is a 200 response.
For instance the request http://localhost:8000/admin/pages/edit/EditForm/7/field/Categories/search?gridfield_relationsearch=tr returns the response [{"label":"Travel","value":"Travel","id":1}]

But the dropdown of the relationEditor never appears and the spinner keeps spinning.

In the console there is the following error:

vendor.js?m=1670898567:1 Uncaught TypeError: r.getClientRects is not a function
    at e.fn.init.offset (vendor.js?m=1670898567:1:807306)
    at Object.getWithinInfo (vendor.js?m=1670898567:1:2263439)
    at t.fn.position (vendor.js?m=1670898567:1:2263710)
    at e.fn.position (vendor.js?m=1670898567:1:2268466)
    at e.<computed>.<computed>._suggest (vendor.js?m=1670898567:1:2352878)
    at e.<computed>.<computed>._suggest (vendor.js?m=1670898567:1:2253949)
    at e.<computed>.<computed>.__response (vendor.js?m=1670898567:1:2352181)
    at e.<computed>.<computed>.__response (vendor.js?m=1670898567:1:2253949)
    at e.<computed>.<computed>.o (vendor.js?m=1670898567:1:2253833)
    at e.<computed>.<computed>.__response (vendor.js?m=1670898567:1:2354345)

Steps to Reproduce

  1. Use the source code of the SilverStripe many_many lesson available at: https://github.com/silverstripe/silverstripe-lessons-v4/tree/master/Lesson-10-end/app/src
  2. In ArticlePage.php replace the CheckboxSetField with a GridFieldConfig_RelationEditor
//        $fields->addFieldToTab('Root.Categories', CheckboxSetField::create(
//            'Categories',
//            'Selected categories',
//            $this->Parent()->Categories()->map('ID','Title')
//        ));

$conf = GridFieldConfig_RelationEditor::create(10);
$fields->addFieldToTab('Root.Categories', new GridField('Categories', 'Categories', $this->Categories(), $conf));
  1. Login the CMS
  2. Create sample categories
  3. Create a ArticlePage and try to link a category
@kinglozzer
Copy link
Member

Could well be related to #1423 (i.e. jQuery UI needing to be updated - #1424)

@kinglozzer kinglozzer transferred this issue from silverstripe/silverstripe-framework Jan 3, 2023
@GuySartorelli GuySartorelli changed the title GridField relation editor JavaScript error 1.12 GridField relation editor JavaScript error Jan 8, 2023
@ssmarco
Copy link

ssmarco commented Jan 9, 2023

Another way of manual testing is going to Security -> Groups section. And then click either Content Authors or Administrators from the list. From there the relation editor shows up to find existing member as shown below:
image

@lekoala
Copy link
Contributor

lekoala commented Jan 9, 2023

Yes I can confirm I have the same issue, I'm currently looking into it

image

@lekoala
Copy link
Contributor

lekoala commented Jan 9, 2023

in the meantime.. if you have the issue, this works after leftandmain init.

    Requirements::javascript("https://code.jquery.com/jquery-migrate-3.4.0.min.js");

@sb-relaxt-at
Copy link

In case this helps someone in debugging: r is the window whereas I assume it should be some dom element. It seems as this inside the entwine function no longer points to the owning dom element. Due to the suggestion by @lekoala I assume it is related to the jQuery update.

@sb-relaxt-at
Copy link

Could well be related to #1423 (i.e. jQuery UI needing to be updated - #1424)

From my short debugging session I do agree, that seems to be the same problem.

@GuySartorelli
Copy link
Member

@liefra silverstripe/admin 1.12.1 has been released - can you please check if that fixes this issue for you?

@liefra
Copy link
Author

liefra commented Jan 12, 2023

@GuySartorelli : Hi, I have upgraded two projects to silverstripe/admin 1.12.1 and for both the error is gone and linking records work again as expected. Thanks a lot

@GuySartorelli
Copy link
Member

Awesome. Closing this issue then.

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

No branches or pull requests

7 participants