Skip to content

Commit edbb92b

Browse files
MC-39128: Cannot delete second layout update in widget
1 parent 78c411d commit edbb92b

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

app/code/Magento/Backend/Block/Widget/Button.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66
namespace Magento\Backend\Block\Widget;
77

8+
use Magento\Backend\Block\Template\Context;
89
use Magento\Framework\App\ObjectManager;
910
use Magento\Framework\Math\Random;
10-
use Magento\Backend\Block\Template\Context;
1111
use Magento\Framework\View\Helper\SecureHtmlRenderer;
1212

1313
/**
@@ -125,6 +125,9 @@ protected function _prepareAttributes($title, $classes, $disabled)
125125
'value' => $this->getValue(),
126126
'disabled' => $disabled,
127127
];
128+
if ($this->hasData('onclick_attribute')) {
129+
$attributes['onclick'] = $this->getData('onclick_attribute');
130+
}
128131
if ($this->hasData('backend_button_widget_hook_id')) {
129132
$attributes['backend-button-widget-hook-id'] = $this->getData('backend_button_widget_hook_id');
130133
}

app/code/Magento/Backend/Test/Unit/Block/Widget/ButtonTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,16 @@ public function getAttributesHtmlDataProvider()
9494
]
9595
];
9696
}
97+
98+
/**
99+
* Verifies ability of adding button onclick attribute
100+
*
101+
* @return void
102+
*/
103+
public function testOnClickAttribute(): void
104+
{
105+
$this->_blockMock->setData(['onclick_attribute' => 'value']);
106+
$attributes = $this->_blockMock->getAttributesHtml();
107+
$this->assertStringContainsString('onclick', $attributes);
108+
}
97109
}

app/code/Magento/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/Main/Layout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public function getRemoveLayoutButtonHtml()
327327
)->setData(
328328
[
329329
'label' => $this->escapeHtmlAttr(__('Remove Layout Update')),
330-
'onclick' => 'WidgetInstance.removePageGroup(this)',
330+
'onclick_attribute' => 'WidgetInstance.removePageGroup(this)',
331331
'class' => 'action-delete',
332332
]
333333
);

0 commit comments

Comments
 (0)