Skip to content

Commit a35ee4e

Browse files
committed
Fixed duplicate ids when multiple tooltipped element found on the page
1 parent 6c1807b commit a35ee4e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

app/code/Magento/Ui/view/base/web/js/form/element/abstract.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ define([
131131
uid: uid,
132132
noticeId: 'notice-' + uid,
133133
errorId: 'error-' + uid,
134+
tooltipId: 'tooltip-' + uid,
134135
inputName: utils.serializeName(name.join('.')),
135136
valueUpdate: valueUpdate
136137
});

app/code/Magento/Ui/view/frontend/web/templates/form/element/helper/tooltip.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
data-bind="attr: {href: tooltip.link}, mageInit: {'dropdown':{'activeClass': '_active'}}"></a>
1414
<!-- /ko -->
1515

16-
<span id="tooltip-label" class="label"><!-- ko i18n: 'Tooltip' --><!-- /ko --></span>
16+
<span class="label" data-bind="attr: { id: $data.tooltipId ? $data.tooltipId : 'tooltip-label' }"><!-- ko i18n: 'Tooltip' --><!-- /ko --></span>
1717
<!-- ko if: (!tooltip.link)-->
1818
<span
19-
id="tooltip"
2019
class="field-tooltip-action action-help"
2120
tabindex="0"
2221
data-toggle="dropdown"
23-
data-bind="mageInit: {'dropdown':{'activeClass': '_active', 'parent': '.field-tooltip.toggle'}}"
24-
aria-labelledby="tooltip-label"
22+
data-bind="
23+
mageInit: {'dropdown':{'activeClass': '_active', 'parent': '.field-tooltip.toggle'}},
24+
attr: { 'aria-labelledby': $data.tooltipId ? $data.tooltipId : 'tooltip-label' }
25+
"
2526
>
2627
</span>
2728
<!-- /ko -->

0 commit comments

Comments
 (0)