Skip to content

Commit

Permalink
fix: address field in gmaps, cloneable group
Browse files Browse the repository at this point in the history
  • Loading branch information
tanftw committed Dec 13, 2024
1 parent 22d949d commit a7130ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
18 changes: 11 additions & 7 deletions js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,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
10 changes: 5 additions & 5 deletions js/osm.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,18 @@
return $address;
}

let groupWrapper = this.$container.closest( '.rwmb-group-clone' );
if ( ! groupWrapper.length ) {
groupWrapper = this.$container.closest( '.rwmb-group-wrapper' );
let $groupWrapper = this.$container.closest( '.rwmb-group-clone' );
if ( ! $groupWrapper.length ) {
$groupWrapper = this.$container.closest( '.rwmb-group-wrapper' );
}

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

selector = `input[name*="${ fieldName }"], select[name*="${ fieldName }"]`;

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

0 comments on commit a7130ba

Please sign in to comment.