Skip to content

Commit

Permalink
Fixed #14134
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jan 16, 2024
1 parent 3426cb3 commit 6f018da
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fixed a bug where `Craft.FormObserver` wasn’t working reliably for non-`<form>` containers.
- Fixed a bug where Selectize inputs were triggering autosaves, even when the value didn’t change.
- Fixed a bug where custom source labels weren’t getting translated. ([#14137](https://github.com/craftcms/cms/issues/14137))
- Fixed a bug where Dropdown columns within Table fields were loosing their options when the field was edited. ([#14134](https://github.com/craftcms/cms/issues/14134))

## 4.6.0 - 2024-01-09

Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

44 changes: 26 additions & 18 deletions src/web/assets/cp/src/js/EditableTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,33 @@ Craft.EditableTable = Garnish.Base.extend(
this.updateAddRowButton();
this.addListener(this.$addRowBtn, 'activate', 'addRow');

// Lazily create the row objects
this.addListener(
this.$tbody,
'keypress,keyup,change,focus,blur,click,mousedown,mouseup',
(ev) => {
const $target = $(ev.target);
const $tr = $target.closest('tr');
if ($tr.length && !$tr.data('editable-table-row')) {
const $textarea = $target.hasClass('editable-table-preview')
? $target.next()
: null;
this.createRowObj($tr);
setTimeout(() => {
if ($textarea && !$textarea.is(':focus')) {
$textarea.trigger('focus');
}
}, 100);
if (this.settings.lazyInitRows) {
// Lazily create the row objects
this.addListener(
this.$tbody,
'keypress,keyup,change,focus,blur,click,mousedown,mouseup',
(ev) => {
const $target = $(ev.target);
const $tr = $target.closest('tr');
if ($tr.length && !$tr.data('editable-table-row')) {
const $textarea = $target.hasClass('editable-table-preview')
? $target.next()
: null;
this.createRowObj($tr);
setTimeout(() => {
if ($textarea && !$textarea.is(':focus')) {
$textarea.trigger('focus');
}
}, 100);
}
}
);
} else {
const $rows = this.$tbody.children();
for (let i = 0; i < $rows.length; i++) {
this.createRowObj($rows.eq(i));
}
);
}

return true;
},
Expand Down Expand Up @@ -419,6 +426,7 @@ Craft.EditableTable = Garnish.Base.extend(
allowDelete: false,
minRows: null,
maxRows: null,
lazyInitRows: true,
onAddRow: $.noop,
onDeleteRow: $.noop,
},
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/tablesettings/dist/TableFieldSettings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/web/assets/tablesettings/src/TableFieldSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
allowAdd: true,
allowReorder: true,
allowDelete: true,
lazyInitRows: false,
onAddRow: this.onAddColumn.bind(this),
onDeleteRow: this.reconstructDefaultsTable.bind(this),
}
Expand Down

0 comments on commit 6f018da

Please sign in to comment.