Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Fixed a bug where element queries weren’t returning any results if they had a param that resolved to multiple generated fields. ([#17709](https://github.com/craftcms/cms/issues/17709))
- Fixed a bug where Link fields weren’t preserving spaces within Phone and SMS link labels. ([#17707](https://github.com/craftcms/cms/issues/17707))
- Fixed a bug where disabled rows within element selector modals could contain nested focusable elements. ([#17053](https://github.com/craftcms/cms/pull/17053))
- Fixed a bug where <kbd>Ctrl</kbd>/<kbd>Command</kbd> + <kbd>A</kbd> wasn’t selecting all elements within element indexes. ([#17033](https://github.com/craftcms/cms/pull/17033))

## 5.8.12 - 2025-07-29

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

38 changes: 33 additions & 5 deletions src/web/assets/garnish/src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ import $ from 'jquery';

/**
* Select
* Selection interface
*/
export default Base.extend(
{
/**
* The jQuery object representing the container element.
* @type {jQuery}
*/
$container: null,
$items: null,
$selectedItems: null,
Expand Down Expand Up @@ -569,10 +574,19 @@ export default Base.extend(
* Sets the focus on an item.
*/
focusItem: function ($item, preventScroll) {
let $focusableElement;
if (this.settings.makeFocusable) {
this.setFocusableItem($item);
$item[0].focus({preventScroll: !!preventScroll});
$focusableElement = $item;
} else if ($item.is(':focusable')) {
$focusableElement = $item;
} else {
$focusableElement = $item.find(':focusable:first');
}
if ($focusableElement?.length) {
$focusableElement[0].focus({preventScroll: !!preventScroll});
}

this.$focusedItem = $item;
this.trigger('focusItem', {item: $item});
},
Expand Down Expand Up @@ -693,10 +707,15 @@ export default Base.extend(
*/
onKeyDown: function (ev) {
// Ignore if the focus isn't on one of our items or their handles
if (
ev.target !== ev.currentTarget &&
!$.data(ev.currentTarget, 'select-handle')?.filter(ev.target).length
) {
const itemIsTarget = ev.target == ev.currentTarget;
const handleIsTarget = $.data(ev.currentTarget, 'select-handle')?.filter(
ev.target
).length;
const checkboxIsTarget =
this.settings.checkboxClass &&
$(ev.target).hasClass(this.settings.checkboxClass);

if (!itemIsTarget && !handleIsTarget && !checkboxIsTarget) {
return;
}

Expand Down Expand Up @@ -945,8 +964,17 @@ export default Base.extend(
allowEmpty: true,
vertical: false,
horizontal: false,
/**
* The handle for selecting items.
* Can be a string (selector), a function, or an object.
* @type {string|function|object|null}
*/
handle: null,
filter: null,
/**
* Whether checkbox selection determines selected items
* @type {boolean}
*/
checkboxMode: false,
makeFocusable: false,
waitForDoubleClicks: false,
Expand Down