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

contentpreview-edit.js doesn't declare jQuery as its dependency #15181

Closed
Psichorex opened this issue Jan 27, 2024 · 10 comments · Fixed by #15183
Closed

contentpreview-edit.js doesn't declare jQuery as its dependency #15181

Psichorex opened this issue Jan 27, 2024 · 10 comments · Fixed by #15183
Labels

Comments

@Psichorex
Copy link
Contributor

Describe the bug

After upgrading to Orchard Core 1.8 some preview buttons inside of content item editors become broken.
They are broken because the driving script behind it called contentpreview-edit has an exception of:
6587e414-77ca-4ba6-bb94-96c3be0bf8d1
$ is not defined is almost always due to a script being called before jQuery is registered.
Same happens in Orchard Core as the problematic content items have contentpreview-edit script registered prior to jquery.js
Making a code that brings jquery in front resolved the problem.

contentpreview-edit doesn't declare jquery as it's dependency:
Nor in its corresponding ResourceManagementOptionsConfiguration
https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.ContentPreview/ResourceManagementOptionsConfiguration.cs#L14-L17
Nor in the script inclusion in the Razor.
https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.ContentPreview/Views/ContentPreview.Button.cshtml#L22

I can't write a direct way of reproducing this because when I am creating a Content Type from the Admin page it works but Content Types that are coming from Migrations and custom code are broken.

Either way contentpreview-edit should have jquery declared as its dependency.

@Piedone
Copy link
Member

Piedone commented Jan 27, 2024

Please provide repro steps so we can check it being broken and indeed fixed after adding a dependency.

@Psichorex
Copy link
Contributor Author

@Piedone I can only provide reprosteps for our OSOCE repository.
But it's basically go to ContentItems list and open any custom type:
image
image
image

Also there are pages where it's working:

image

Where it's not working all those pages have contentpreview-edit registered first and jquery just after.

@Piedone
Copy link
Member

Piedone commented Jan 27, 2024

Please provide an export of the content type you're using. Something is different than the built-in Blog Post, since if you check that with the latest source, this doesn't happen.

@Piedone
Copy link
Member

Piedone commented Jan 27, 2024

And first make sure that this also happens with the OC source, i.e. it's not caused by anything in the custom solution.

@MikeAlhayek
Copy link
Member

MikeAlhayek commented Jan 27, 2024

This is probably an issue after upgrading the admin theme. Can you submit a PR to adding to this?
@Psichorex can you submit a PR by adding the line .SetDependencies("jQuery") to this?

We should spend time to remove jQuery from these older scripts.

@Psichorex
Copy link
Contributor Author

This is probably an issue after upgrading the admin theme. Can you submit a PR to adding to this? @Psichorex can you submit a PR by adding the line .SetDependencies("jQuery") to this?

We should spend time to remove jQuery from these older scripts.

@MikeAlhayek Seems like I don't have the permission to commit. I thought I was added as a contributor. TL:DR I can't open a PR.

@Piedone
Copy link
Member

Piedone commented Jan 27, 2024

You need to work in a fork.

@Psichorex
Copy link
Contributor Author

I will add this in our fork.

@MikeAlhayek
Copy link
Member

yes create a branch out of your fork. then create a cross repository into OC main branch. Feel free to ping me when you create the PR.

@Psichorex
Copy link
Contributor Author

@MikeAlhayek here is the PR in our Fork
#15183

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

Successfully merging a pull request may close this issue.

3 participants