Skip to content

Commit

Permalink
Don't submit the form on Return press for FLD search inputs
Browse files Browse the repository at this point in the history
Resolves #11415
  • Loading branch information
brandonkelly committed Jun 9, 2022
1 parent 7410544 commit 28910a3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Changed
- Element index queries are no longer cached if they contain a search term.
- Search inputs within field layout designers now prevent the containing form from being submitted when the <kbd>Return</kbd> key is pressed. ([#11415](https://github.com/craftcms/cms/discussions/11415))

### Fixed
- Fixed a bug where element types’ `actions()` methods were getting called for all `element-indexes/*` action requests.
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.

10 changes: 8 additions & 2 deletions src/web/assets/cp/src/js/FieldLayoutDesigner.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,14 @@ Craft.FieldLayoutDesigner = Garnish.Base.extend(
});

this.addListener(this.$fieldSearch, 'keydown', (ev) => {
if (ev.keyCode === Garnish.ESC_KEY) {
this.$fieldSearch.val('').trigger('input');
switch (ev.keyCode) {
case Garnish.ESC_KEY:
this.$fieldSearch.val('').trigger('input');
break;
case Garnish.RETURN_KEY:
// they most likely don't want to submit the form from here
ev.preventDefault();
break;
}
});

Expand Down

0 comments on commit 28910a3

Please sign in to comment.