8000 fix: CMS widgets need not load if they are read only by fsbraun · Pull Request #7880 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

fix: CMS widgets need not load if they are read only #7880

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

Merged
merged 11 commits into from
Apr 23, 2024

Conversation

fsbraun
Copy link
Member
@fsbraun fsbraun commented Apr 18, 2024

Description

In django CMS 4 form fields that use CMS widgets might be read-only (e.g., if the version is published). In that case, widgets are not loaded into window.CMS.Widgets. This PR only activates widgets if they are loaded.

Fixes #7879.

This PR does not change any logic (only prevents a js script error to be thrown), hence no tests.

Related resources

Checklist

  • I have opened this pull request against develop-4
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined #workgroup-pr-review on Slack to find a “pr review buddy” who is going to review my pull request.

@jrief
Copy link
Contributor
jrief commented Apr 18, 2024

Yes, this PR fixes the problem.

For curiosity, is it intended that window.CMS.Widgets._pageSelectWidgets might be undefined?

Copy link
Contributor
@jrief jrief left a comment

Choose a reason for hiding this comment

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

Wouldn't it be nicer to write:

window.CMS.Widgets?._pageSelectWidgets?.forEach

@fsbraun
Copy link
Member Author
fsbraun commented Apr 18, 2024

@jrief Good news.

I hesitate to use optional chaining, since it is "only" supported by newer browsers (~95% according to can I use). django CMS' whole JS code base does not use it and I reckon the two lines are not worth starting to think about compatibility.

@fsbraun fsbraun requested a review from jrief April 20, 2024 09:10
@fsbraun fsbraun merged commit fb30434 into django-cms:develop-4 Apr 23, 2024
@fsbraun fsbraun deleted the fix/issue-7879 branch January 10, 2025 19:31
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.

[BUG] Console error in browser when opening PageContentAdmin
3 participants
0