Skip to content
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

feat: osm autocomplete inside group #1623

Merged
merged 2 commits into from
Dec 13, 2024
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
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
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
Loading