Skip to content

Commit

Permalink
pass an element, not CSS selector as customOpener setting value
Browse files Browse the repository at this point in the history
  • Loading branch information
kkarpieszuk committed Nov 15, 2023
1 parent 4f5b6a8 commit 6785518
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/wpforms-multiselect-checkboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// Default delimiter for the input value.
// This is an undocumented option which might not often be used, but it's here for convenience.
delimiter: ', ',
// Default custom opener. User can specify here custom CSS selector for the element which will open the dropdown.
// Default custom opener. User can pass a custom element to open the dropdown.
customOpener: null,
};

Expand Down Expand Up @@ -550,7 +550,7 @@
}

// If custom opener is clicked, do not close the dropdown.
if ( this.settings.customOpener && document.querySelector( this.settings.customOpener )?.contains( target ) ) {
if ( this.settings.customOpener && this.settings.customOpener?.contains( target ) ) {
return;
}

Expand All @@ -576,9 +576,7 @@
document.addEventListener( 'click', handleDocumentClick );

if ( this.settings.customOpener ) {
document.querySelectorAll( this.settings.customOpener )?.forEach( ( opener ) => {
opener.addEventListener( 'click', handleInputClick );
} );
this.settings.customOpener.addEventListener( 'click', handleInputClick );
}

// Bind event listeners for selected options, if enabled.
Expand Down

0 comments on commit 6785518

Please sign in to comment.