Skip to content

Commit 4a987c7

Browse files
authored
Merge pull request #17105 from craftcms/bugfix/17099-nested-element-edit-btn-and-focus
card edit button and focus
2 parents dab732d + 08bf3db commit 4a987c7

File tree

5 files changed

+7
-2
lines changed

5 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Fixed a SQL error that could occur when executing an element query, if the `orderBy` param contained unexpected syntax.
66
- Fixed a bug where nested element cards could be missing their action menus if their “Max” setting had been reached. ([#17103](https://github.com/craftcms/cms/issues/17103))
7+
- Fixed a bug where focus wasn’t always returned to the edit button, when closing an element editor slideout. ([#17099](https://github.com/craftcms/cms/issues/17099))
78
- Fixed styling issues. ([#17100](https://github.com/craftcms/cms/pull/17100), [#17098](https://github.com/craftcms/cms/issues/17098))
89

910
## 5.7.0 - 2025-04-15

src/helpers/Cp.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ public static function elementCardHtml(ElementInterface $element, array $config
629629
if ($cpEditUrl && Garnish.isCtrlKeyPressed(ev.originalEvent)) {
630630
window.open($cpEditUrl);
631631
} else {
632+
// focus on the button so that when the slideout is closed, it's returned to the button
633+
$(ev.currentTarget).focus();
632634
Craft.createElementEditor($elementType, $settings);
633635
}
634636
});

src/web/assets/cp/dist/cp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/cp/dist/cp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/cp/src/js/NestedElementManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ Craft.NestedElementManager = Garnish.Base.extend(
581581
// Override the default event listener
582582
$editBtn.off('activate');
583583
this.addListener($editBtn, 'activate', (ev) => {
584+
// focus on the button so that when the slideout is closed, it's returned to the button
585+
$editBtn.focus();
584586
const cpUrl = $element.data('cpUrl');
585587
if (cpUrl && Garnish.isCtrlKeyPressed(ev.originalEvent)) {
586588
window.open(cpUrl);

0 commit comments

Comments
 (0)