Skip to content

Commit

Permalink
Merge pull request #4029 from impress-org/hotfix/select_autocomplete
Browse files Browse the repository at this point in the history
fix: ensure do not set default autocomplete on every dropdown fields #4028
  • Loading branch information
Devin Walker committed Mar 4, 2019
2 parents 29f3908 + b9cfece commit f789fab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions includes/admin/class-give-html-elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ public function select( $args = array() ) {
'name' => null,
'class' => '',
'id' => '',
'autocomplete' => 'no',
'selected' => 0,
'chosen' => false,
'placeholder' => null,
Expand Down Expand Up @@ -489,14 +490,15 @@ public function select( $args = array() ) {
}

$output = sprintf(
'<select name="%1$s" id="%2$s" autocomplete="address-level4" class="give-select %3$s" %4$s %5$s placeholder="%6$s" data-placeholder="%6$s" %7$s>',
'<select name="%1$s" id="%2$s" autocomplete="%8$s" class="give-select %3$s" %4$s %5$s placeholder="%6$s" data-placeholder="%6$s" %7$s>',
esc_attr( $args['name'] ),
esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ),
esc_attr( $args['class'] ),
$multiple,
$args['select_atts'],
$placeholder,
$data_elements
$data_elements,
$args['autocomplete']
);

if ( $args['show_option_all'] ) {
Expand Down
6 changes: 4 additions & 2 deletions includes/admin/donors/donors.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ function give_donor_view( $donor ) {
'chosen' => true,
'placeholder' => esc_attr__( 'Select a country', 'give' ),
'data' => array( 'search-type' => 'no_ajax' ),
'autocomplete' => 'country',
) );
?>
</td>
Expand Down Expand Up @@ -676,8 +677,9 @@ function give_donor_view( $donor ) {
<?php
$states = give_get_states( $base_country );
$state_args = array(
'name' => 'state',
'class' => 'regular-text',
'name' => 'state',
'class' => 'regular-text',
'autocomplete' => 'address-level1',
);

if ( empty( $states ) ) {
Expand Down
4 changes: 3 additions & 1 deletion includes/admin/payments/view-payment-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@
'chosen' => true,
'placeholder' => esc_attr__( 'Select a country', 'give' ),
'data' => array( 'search-type' => 'no_ajax' ),
'autocomplete' => 'country',
)
);
?>
Expand Down Expand Up @@ -796,11 +797,12 @@
'chosen' => true,
'placeholder' => esc_attr__( 'Select a state', 'give' ),
'data' => array( 'search-type' => 'no_ajax' ),
'autocomplete' => 'address-level1',
)
);
} else {
?>
<input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr( $address['state'] ); ?>" class="medium-text"/>
<input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" autocomplete="address-line1" value="<?php echo esc_attr( $address['state'] ); ?>" class="medium-text"/>
<?php
}
?>
Expand Down
3 changes: 2 additions & 1 deletion includes/ajax-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ function give_ajax_get_states_field() {

$states = give_get_states( $country );
if ( ! empty( $states ) ) {
$args = array(
$args = array(
'name' => $field_name,
'id' => $field_name,
'class' => $field_name . ' give-select',
Expand All @@ -248,6 +248,7 @@ function give_ajax_get_states_field() {
'show_option_none' => false,
'placeholder' => $label,
'selected' => $default_state,
'autocomplete' => 'address-level1',
);
$data = Give()->html->select( $args );
$states_found = true;
Expand Down

0 comments on commit f789fab

Please sign in to comment.