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

Fix broken Learning Mode templates on Gutenberg 17.1.0 #7317

Merged
merged 5 commits into from Nov 22, 2023

Conversation

donnapep
Copy link
Collaborator

@donnapep donnapep commented Nov 22, 2023

Proposed Changes

Comments out code that was erroneously unregistering Sensei's blocks for the Learning Mode templates (see screenshot below). UPDATE: Return early if the post type is wp_template (prior to Gutenberg 17.1.0 the call to getCurrentPostType would return null).

The original intention of this code appears to have been to only make Sensei's blocks available for the Learning Mode templates. However, this code wasn't working regardless because the call to getCurrentPostType always returned null, which meant the call to unregister the blocks never actually fired because it returned early.

This is a quick fix to get things back to working how they were before, but we will need to create a separate issue to properly unregister Sensei blocks for non-Learning Mode templates (which likely hasn't worked for quite some time, if ever).

Before

Screenshot 2023-11-22 at 10 35 39 AM (4)

Testing Instructions

  1. Activate Gutenberg 17.1.0.
  2. In the site editor, check that the Lesson and Quiz Learning Mode templates load.
  3. Check that the same Sensei blocks are still loaded for courses, lessons, posts and pages as they did before.

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Acceptance criteria is met
  • Decisions are publicly documented
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • New UIs match the designs
  • Different user privileges (admin, teacher, subscriber) are tested as appropriate
  • Code is tested on the minimum supported PHP and WordPress versions
  • User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
  • "Needs Documentation" label is added if this change requires updates to documentation
  • Known issues are created as new GitHub issues

@donnapep donnapep added this to the 4.19.2 milestone Nov 22, 2023
@donnapep donnapep self-assigned this Nov 22, 2023
Copy link

github-actions bot commented Nov 22, 2023

WordPress Dependencies Report

The github-action-wordpress-dependencies-report action has detected some script changes between the commit bf44ab2 and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Dependencies Removed Dependencies Total Size Size Diff
course-theme/blocks/index.js 13.8 kB +11 B ( +0.08% 🔼 )

This comment was automatically generated by the github-action-wordpress-dependencies-report action.

@donnapep donnapep requested a review from a team November 22, 2023 21:13
Copy link

codecov bot commented Nov 22, 2023

Codecov Report

Merging #7317 (bf44ab2) into trunk (592cd74) will not change coverage.
Report is 1 commits behind head on trunk.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              trunk    #7317   +/-   ##
=========================================
  Coverage     50.81%   50.81%           
  Complexity    11060    11060           
=========================================
  Files           611      611           
  Lines         46727    46727           
  Branches        404      404           
=========================================
  Hits          23744    23744           
  Misses        22656    22656           
  Partials        327      327           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f0604f1...bf44ab2. Read the comment docs.

@renatho
Copy link
Contributor

renatho commented Nov 22, 2023

I noticed that different from trunk, it's registering all template blocks for the lesson, which could confuse the users, not knowing what blocks are useful there and what blocks are not.

Screenshot 2023-11-22 at 18 34 09

I wonder if we could keep only part of that logic to unregister the blocks for the lesson editor. WDYT?

@donnapep
Copy link
Collaborator Author

donnapep commented Nov 22, 2023

it's registering all template blocks for the lesson

Nice catch! I thought the blocks would show up under the Sensei LMS category, not theme. 🤨 I made a change in 11c2bef to return early if we're in the site editor.

Copy link
Contributor

@renatho renatho left a comment

Choose a reason for hiding this comment

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

Thank you! It works for me now, and the blocks are only available on the template editor.

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.

None yet

2 participants