Skip to content

Commit 286e513

Browse files
authored
Fix subform: add row at correct position (#34402)
1 parent 1f94006 commit 286e513

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

build/media_source/system/js/fields/joomla-field-subform.w-c.es6.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@
9696

9797
// Check active, with extra check for nested joomla-field-subform
9898
if (btnAdd && btnAdd.closest('joomla-field-subform') === that) {
99-
let row = btnAdd.closest('joomla-field-subform');
100-
row = row.closest(that.repeatableElement) === that ? row : null;
99+
let row = btnAdd.closest(that.repeatableElement);
100+
row = row && row.closest('joomla-field-subform') === that ? row : null;
101101
that.addRow(row);
102102
event.preventDefault();
103103
} else if (btnRem && btnRem.closest('joomla-field-subform') === that) {
@@ -113,8 +113,9 @@
113113
const isRem = that.buttonRemove && event.target.matches(that.buttonRemove);
114114

115115
if ((isAdd || isRem) && event.target.closest('joomla-field-subform') === that) {
116-
let row = event.target.closest('joomla-field-subform');
117-
row = row.closest(that.repeatableElement) === that ? row : null;
116+
let row = event.target.closest(that.repeatableElement);
117+
row = row && row.closest('joomla-field-subform') === that ? row : null;
118+
118119
if (isRem && row) {
119120
that.removeRow(row);
120121
} else if (isAdd) {

0 commit comments

Comments
 (0)