Skip to content
Snippets Groups Projects
Commit 7c636a64 authored by rhovland's avatar rhovland Committed by Jonathan Sacksick
Browse files

Issue #3447691: Variation field renderer AJAX inserts div tags which can effect layout

parent 962b4c8e
No related branches found
No related tags found
No related merge requests found
Pipeline #179164 passed
......@@ -112,10 +112,11 @@ class ProductVariationFieldRenderer implements ProductVariationFieldRendererInte
if (isset($rendered_field['#type']) && $rendered_field['#type'] == 'view') {
return $rendered_field;
}
// Ensure that a <div> is rendered even if the field is empty, to allow
// Ensure that a <span> is rendered even if the field is empty, to allow
// field replacement to work when the variation changes.
if (!Element::children($rendered_field)) {
$rendered_field['#type'] = 'container';
$rendered_field['#type'] = 'html_tag';
$rendered_field['#tag'] = 'span';
}
}
......
......@@ -176,7 +176,7 @@ class ProductVariationFieldRendererTest extends CommerceKernelTestBase {
$this->assertArrayHasKey('list_price', $rendered_fields);
$this->assertNotEmpty($rendered_fields['list_price']);
$this->assertEquals('product--variation-field--variation_list_price__' . $variation->getProductId(), $rendered_fields['list_price']['#ajax_replace_class']);
$this->assertEquals('container', $rendered_fields['list_price']['#type']);
$this->assertEquals('html_tag', $rendered_fields['list_price']['#type']);
$product_view_builder = $this->container->get('entity_type.manager')->getViewBuilder('commerce_product');
$product_build = $product_view_builder->view($product);
......@@ -323,7 +323,7 @@ class ProductVariationFieldRendererTest extends CommerceKernelTestBase {
$rendered_field = $this->variationFieldRenderer->renderField('list_price', $variation, 'default');
$this->assertNotEmpty($rendered_field);
$this->assertEquals('product--variation-field--variation_list_price__' . $variation->getProductId(), $rendered_field['#ajax_replace_class']);
$this->assertEquals('container', $rendered_field['#type']);
$this->assertEquals('html_tag', $rendered_field['#type']);
// Confirm that hidden fields don't get AJAX classes.
$rendered_field = $this->variationFieldRenderer->renderField('price', $variation, 'default');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment