Skip to content

Commit

Permalink
fix(xblock): ensure TagCountFactory is bundled in production
Browse files Browse the repository at this point in the history
Remove the `static:webpack` directive and use `add_webpack_js_to_fragment`
to properly include TagCountFactory in production. The previous solution
did not correctly bundle this factory, causing the `ReferenceError:
TagCountFactory is not defined` JS error in the Studio preview.
  • Loading branch information
Agrendalath committed Jan 7, 2025
1 parent 8612f2a commit 57ac262
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions cms/djangoapps/contentstore/views/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
}

add_webpack_js_to_fragment(frag, "js/factories/xblock_validation")
add_webpack_js_to_fragment(frag, "js/factories/tag_count")

html = render_to_string('studio_xblock_wrapper.html', template_context)
frag = wrap_fragment(frag, html)
Expand Down
13 changes: 5 additions & 8 deletions cms/templates/studio_xblock_wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,14 @@
${bool(block_is_unit) | n, dump_js_escaped_json}, // block_is_unit will be None or a boolean
$('div.xblock-validation-messages[data-locator="${xblock.location | n, js_escaped_string}"]')
);
</script>

<%static:webpack entry="js/factories/tag_count">
TagCountFactory({
tags_count: "${tags_count | n, js_escaped_string}",
content_id: "${xblock.location | n, js_escaped_string}",
course_authoring_url: "${course_authoring_url | n, js_escaped_string}",
},
tags_count: "${tags_count | n, js_escaped_string}",
content_id: "${xblock.location | n, js_escaped_string}",
course_authoring_url: "${course_authoring_url | n, js_escaped_string}",
},
$('li.tag-count[data-locator="${xblock.location | n, js_escaped_string}"]')
);
</%static:webpack>
</script>

% if not is_root:
% if is_reorderable:
Expand Down

0 comments on commit 57ac262

Please sign in to comment.