Skip to content

Updates Garnish.Select to allow selectAll on checkbox focus #17033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 5.x
Choose a base branch
from
Open
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
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.

27 changes: 23 additions & 4 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 @@ -693,10 +698,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 +955,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
Loading