Make WordPress Core

Changeset 51086


Ignore:
Timestamp:
06/07/2021 11:48:18 PM (4 years ago)
Author:
joedolson
Message:

Application Passwords: Allow enter key to submit profile form.

Fix the enter key in profile form fields moving focus to the application password input instead of submitting the profile update for. Replace the submit button type used for application passwords with button type="button" and ensure that the enter key's native behavior isn't overwritten.

props audrasjb, alexstine, promz, sabernhardt.
Fixes #52849.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/application-passwords.js

    r50367 r51086  
    149149            } );
    150150        } );
     151    } );
     152
     153    $newAppPassField.on( 'keypress', function ( e ) {
     154        if ( 13 === e.which ) {
     155            e.preventDefault();
     156            $newAppPassButton.trigger( 'click' );
     157        }
    151158    } );
    152159
  • trunk/src/wp-admin/includes/class-wp-application-passwords-list-table.php

    r50931 r51086  
    111111     */
    112112    public function column_revoke( $item ) {
    113         submit_button(
    114             __( 'Revoke' ),
    115             'delete',
    116             'revoke-application-password-' . $item['uuid'],
    117             false,
    118             array(
    119                 /* translators: %s: the application password's given name. */
    120                 'aria-label' => sprintf( __( 'Revoke "%s"' ), $item['name'] ),
    121             )
     113        $name = 'revoke-application-password-' . $item['uuid'];
     114        printf(
     115            '<button type="button" name="%1$s" id="%1$s" class="button delete" aria-label="%2$s">%3$s</button>',
     116            esc_attr( $name ),
     117            /* translators: %s: the application password's given name. */
     118            esc_attr( sprintf( __( 'Revoke "%s"' ), $item['name'] ) ),
     119            __( 'Revoke' )
    122120        );
    123121    }
     
    157155            <?php if ( 'bottom' === $which ) : ?>
    158156                <div class="alignright">
    159                     <?php submit_button( __( 'Revoke all application passwords' ), 'delete', 'revoke-all-application-passwords', false ); ?>
     157                    <button type="button" name="revoke-all-application-passwords" id="revoke-all-application-passwords" class="button delete"><?php _e( 'Revoke all application passwords' ); ?></button>
    160158                </div>
    161159            <?php endif; ?>
     
    236234                case 'revoke':
    237235                    printf(
    238                         '<input type="submit" class="button delete" value="%1$s" aria-label="%2$s">',
    239                         esc_attr__( 'Revoke' ),
     236                        '<button type="button" class="button delete" aria-label="%1$s">%2$s</button>',
    240237                        /* translators: %s: the application password's given name. */
    241                         esc_attr( sprintf( __( 'Revoke "%s"' ), '{{ data.name }}' ) )
     238                        esc_attr( sprintf( __( 'Revoke "%s"' ), '{{ data.name }}' ) ),
     239                        esc_html__( 'Revoke' )
    242240                    );
    243241                    break;
  • trunk/src/wp-admin/user-edit.php

    r50932 r51086  
    781781                ?>
    782782
    783                 <?php submit_button( __( 'Add New Application Password' ), 'secondary', 'do_new_application_password' ); ?>
     783                <button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
    784784            </div>
    785785        <?php } else { ?>
Note: See TracChangeset for help on using the changeset viewer.