Make WordPress Core

Ticket #63912: 63912.diff

File 63912.diff, 3.9 KB (added by paulbonneau, 8 months ago)

63912

  • package.json

    diff --git a/package.json b/package.json
    index f84e4eb040..f0ca3fcd6e 100644
    a b  
    186186                "env:cli": "node ./tools/local-env/scripts/docker.js exec --user wp_php cli wp",
    187187                "env:logs": "node ./tools/local-env/scripts/docker.js logs",
    188188                "env:pull": "node ./tools/local-env/scripts/docker.js pull",
     189                "env:composer": "node ./tools/local-env/scripts/docker.js run -T --rm php composer",
    189190                "test:performance": "wp-scripts test-playwright --config tests/performance/playwright.config.js",
    190191                "test:php": "node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpunit",
    191192                "test:coverage": "npm run test:php -- --coverage-html ./coverage/html/ --coverage-php ./coverage/php/report.php --coverage-text=./coverage/text/report.txt",
  • src/js/_enqueues/admin/tags.js

    diff --git a/src/js/_enqueues/admin/tags.js b/src/js/_enqueues/admin/tags.js
    index 3b6cf2b489..ff7761adb8 100644
    a b jQuery( function($) { 
    3131                if ( r ) {
    3232                        data = t.attr('href').replace(/[^?]*\?/, '').replace(/action=delete/, 'action=delete-tag');
    3333
     34                        tr.children().css('backgroundColor', '#faafaa');
     35
     36                        // Disable pointer events and all form controls/links in the row
     37                        tr.css('pointer-events', 'none');
     38                        tr.find(':input, a').prop('disabled', true).attr('tabindex', -1);
     39
    3440                        /**
    3541                         * Makes a request to the server to delete the term that corresponds to the
    3642                         * delete term button.
    jQuery( function($) { 
    4046                         * @return {void}
    4147                         */
    4248                        $.post(ajaxurl, data, function(r){
     49                                var message;
    4350                                if ( '1' == r ) {
    4451                                        $('#ajax-response').empty();
     52                                        let nextFocus = tr.next( 'tr' ).find( 'a.row-title' );
     53                                        let prevFocus = tr.prev( 'tr' ).find( 'a.row-title' );
     54                                        // If there is neither a next row or a previous row, focus the tag input field.
     55                                        if ( nextFocus.length < 1 && prevFocus.length < 1 ) {
     56                                                nextFocus = $( '#tag-name' ).trigger( 'focus' );
     57                                        } else {
     58                                                if ( nextFocus.length < 1 ) {
     59                                                        nextFocus = prevFocus;
     60                                                }
     61                                        }
     62
    4563                                        tr.fadeOut('normal', function(){ tr.remove(); });
    4664
    4765                                        /**
    jQuery( function($) { 
    5371                                         */
    5472                                        $('select#parent option[value="' + data.match(/tag_ID=(\d+)/)[1] + '"]').remove();
    5573                                        $('a.tag-link-' + data.match(/tag_ID=(\d+)/)[1]).remove();
    56 
     74                                        nextFocus.trigger( 'focus' );
     75                                        message = wp.i18n.__( 'The selected tag has been deleted.' );
     76                       
    5777                                } else if ( '-1' == r ) {
    58                                         $('#ajax-response').empty().append('<div class="notice notice-error"><p>' + wp.i18n.__( 'Sorry, you are not allowed to do that.' ) + '</p></div>');
    59                                         tr.children().css('backgroundColor', '');
     78                                        message = wp.i18n.__( 'Sorry, you are not allowed to do that.' );
     79                                        $('#ajax-response').empty().append('<div class="notice notice-error"><p>' + message + '</p></div>');
     80                                        resetRowAfterFailure( tr );
    6081
    6182                                } else {
    62                                         $('#ajax-response').empty().append('<div class="notice notice-error"><p>' + wp.i18n.__( 'An error occurred while processing your request. Please try again later.' ) + '</p></div>');
    63                                         tr.children().css('backgroundColor', '');
     83                                        message = wp.i18n.__( 'An error occurred while processing your request. Please try again later.' );
     84                                        $('#ajax-response').empty().append('<div class="notice notice-error"><p>' + message + '</p></div>');
     85                                        resetRowAfterFailure( tr );
    6486                                }
     87                                wp.a11y.speak( message, 'assertive' );
    6588                        });
    66 
    67                         tr.children().css('backgroundColor', '#f33');
    6889                }
    6990
    7091                return false;
    7192        });
    7293
     94        /**
     95         * Restores the original UI state of a table row after an AJAX failure.
     96         *
     97         * @param {jQuery} tr The table row to reset.
     98         * @return {void}
     99         */
     100        function resetRowAfterFailure( tr ) {
     101                tr.children().css( 'backgroundColor', '' );
     102                tr.css( 'pointer-events', '' );
     103                tr.find( ':input, a' ).prop( 'disabled', false ).removeAttr( 'tabindex' );
     104        }
     105
    73106        /**
    74107         * Adds a deletion confirmation when removing a tag.
    75108         *