Skip to content

fix: use correct SVG data format for autogenerated zones#518

Merged
kdmccormick merged 1 commit intoopenedx:masterfrom
open-craft:agrendalath/fix-autogenerated-zones
Mar 24, 2026
Merged

fix: use correct SVG data format for autogenerated zones#518
kdmccormick merged 1 commit intoopenedx:masterfrom
open-craft:agrendalath/fix-autogenerated-zones

Conversation

@Agrendalath
Copy link
Copy Markdown
Member

This fixes content type recognition in Chrome 146, caused by https://developer.chrome.com/release-notes/146#data_url_mime_type_parameter_preservation.

Description

This moves SVG metadata from MIME type parameters to the SVG node's data attributes. This way, the content is correctly recognized by Chrome 146.

Testing instructions

  1. Use Chrome 146.
  2. Create a DnDv2 without this branch.
  3. Go to "Edit" -> "Continue".
  4. Select "Generate image automatically" and press the "Generate image and zones" button.
  5. Check that the zone images (next to "Zone definitions") are not displayed correctly.
  6. Fill in a "Description" for each zone, and go to "Continue" -> "Save".
  7. The XBlock should no longer be rendered correctly in both Studio and LMS.
  8. Check out this branch.
  9. See that the XBlock is now rendered correctly, and the zone generation (in the Studio editor) works as well.

Deadline

"None", but it would be nice to fix it sooner rather than later, since it affects all instances.

Other information

Related discussion: https://discuss.openedx.org/t/chrome-version-146-0-x-breaks-on-svg-automatic-generation-for-drag-and-drop-xblock/18618

This fixes content type recognition in Chrome 146.
@Agrendalath Agrendalath self-assigned this Mar 23, 2026
@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @Agrendalath!

This repository is currently maintained by @Agrendalath.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Mar 23, 2026
@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @Agrendalath!

This repository is currently maintained by @Agrendalath.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

if (Object.keys(params).length > 0) {
return params;
}
// Legacy format: params encoded in the MIME type section of the data URI.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I kept it for the editor's compatibility with the previous format. I could have used the converted URI from the backend here, but I wanted to avoid potential side effects, since this editor is quite complex.

var autozone_data = _fn.build.form.zone.calculateAutozoneData(params);
var svg = _fn.tpl.autozoneSvg(autozone_data).trim();
var data_uri_params = _fn.build.encodeDataUriParams({
producer: 'dndv2',
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I hardcoded the producer in the autozone-tpl, since it never changes.

'fields': self.fields,
'showanswer_set': self._field_data.has(self, 'showanswer'), # If false, we're using an inherited value.
'self': self,
'data': six.moves.urllib.parse.quote(json.dumps(self.data)),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is not directly related, but I wanted to ensure that we do not use this data anywhere in the editor.

Comment on lines +686 to +687
if not match:
return data_uri
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This should never happen, but I have added it as a failsafe.

@Agrendalath Agrendalath moved this from Needs Triage to Ready for Review in Contributions Mar 23, 2026
@Agrendalath Agrendalath requested a review from a team March 24, 2026 16:36
@kdmccormick
Copy link
Copy Markdown
Member

Thanks!

@kdmccormick kdmccormick merged commit 58f3879 into openedx:master Mar 24, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in Contributions Mar 24, 2026
@Agrendalath Agrendalath deleted the agrendalath/fix-autogenerated-zones branch March 25, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants