Skip to content

Commit

Permalink
feat: support autocomplete inside group for osm
Browse files Browse the repository at this point in the history
  • Loading branch information
tanftw committed Dec 10, 2024
1 parent 261fc0d commit 37af2de
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions js/osm.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,26 @@

// Find address field based on its name attribute. Auto search inside groups when needed.
findAddressField: function ( fieldName ) {
const selector = `input[name="${ fieldName }"], select[name="${ fieldName }"]`;
let selector = `input[name="${ fieldName }"], select[name="${ fieldName }"]`;

// Not in a group.
let $address = $( selector );
if ( $address.length ) {
return $address;
}

// If map and address is inside a cloneable group.
$address = this.$container.closest( '.rwmb-group-clone' ).find( selector );
if ( $address.length ) {
return $address;
let groupWrapper = this.$container.closest( '.rwmb-group-clone' );
if ( ! groupWrapper.length ) {
groupWrapper = this.$container.closest( '.rwmb-group-wrapper' );
}

if ( ! groupWrapper.length ) {
return null;
}

// If map and address is inside a non-cloneable group.
$address = this.$container.closest( '.rwmb-group-wrapper' ).find( selector );
selector = `input[name*="${ fieldName }"], select[name*="${ fieldName }"]`;

$address = groupWrapper.find( selector );
if ( $address.length ) {
return $address;
}
Expand Down

0 comments on commit 37af2de

Please sign in to comment.