Skip to content

Commit

Permalink
Fixed #12445
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 13, 2022
1 parent 50b5dcf commit 27d8b2e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Fixed a bug where it wasn’t possible to enter `0` in Number fields and numeric column cells within editable tables, using certain keyboard layouts. ([#12412](https://github.com/craftcms/cms/issues/12412))
- Fixed a JavaScript error that could occur when autosaving an entry draft. ([#12445](https://github.com/craftcms/cms/issues/12445))
- Added `Craft.filterInputVal()`.
- Added `Craft.filterNumberInputVal()`.

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.

28 changes: 21 additions & 7 deletions src/web/assets/cp/src/js/DraftEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,13 @@ Craft.DraftEditor = Garnish.Base.extend(
.replace(
new RegExp(`(&fields${lb}[^=]+${rb}${lb})(${idsRE})(${rb})`, 'g'),
(m, pre, id, post) => {
if (!this._filterFieldInputName(pre)) {
let duplicate = false;
try {
duplicate = this._filterFieldInputName(pre);
} catch (e) {
console.warn(`Unexpected input name: ${m}`);
}
if (!duplicate) {
return m;
}
return pre + this.duplicatedElements[id] + post;
Expand All @@ -1264,12 +1270,17 @@ Craft.DraftEditor = Garnish.Base.extend(
(m, name, id) => {
// Ignore param names that end in `[enabled]`, `[type]`, etc.
// (`[sortOrder]` should pass here, which could be set to a specific order index, but *not* `[sortOrder][]`!)
if (
!this._filterFieldInputName(name) ||
name.match(
new RegExp(`${lb}(enabled|sortOrder|type|typeId)${rb}$`)
)
) {
let duplicate = false;
try {
duplicate =
this._filterFieldInputName(name) &&
!name.match(
new RegExp(`${lb}(enabled|sortOrder|type|typeId)${rb}$`)
);
} catch (e) {
console.warn(`Unexpected input name: ${m}`);
}
if (!duplicate) {
return m;
}
return `&${name}=${this.duplicatedElements[id]}`;
Expand All @@ -1289,6 +1300,9 @@ Craft.DraftEditor = Garnish.Base.extend(
const nestedNames = name.match(
new RegExp(`(\\bfields|${lb}fields${rb})${lb}[^${rb}]+${rb}`, 'g')
);
if (!nestedNames) {
throw `Unexpected input name: ${name}`;
}
const lastHandle = nestedNames[nestedNames.length - 1].match(
new RegExp(`(?:\\bfields|${lb}fields${rb})${lb}([^${rb}]+)${rb}`)
)[1];
Expand Down

0 comments on commit 27d8b2e

Please sign in to comment.