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

Fix: List view renders an empty menu when no actions are eligible. #62786

Conversation

jorgefilipecosta
Copy link
Member

If no actions are eligible on the list view we render an empty menu. We are checking for actions?.length while we should check for eligibleActions?.length. This PR fixes the issue.

Testing Instructions

I pasted the following code snippet:

function remove_edit_delete_post_capability( $caps, $cap, $user_id, $args ) {
    if ( 'edit_post' === $cap || 'delete_post' === $cap) {
        // Get the current user object
        $current_user = wp_get_current_user();
        // Check if the current user is the user we want to remove the capability from
        if ( $current_user->ID == $user_id ) {
            // Remove the 'delete_post' capability
            // It's done by returning a capability that the user does not have, for example 'do_not_allow'
            $caps[] = 'do_not_allow';
        }
    }

    return $caps;
}
add_filter( 'map_meta_cap', 'remove_edit_delete_post_capability', 10, 4 );

I went to the trash pages section wp-admin/site-editor.php?postType=page&layout=list&activeView=trash
I verified the actions menu is not available. On trunk it is and renders an empty menu:
Screenshot 2024-06-21 at 17 25 03

@jorgefilipecosta jorgefilipecosta added the [Type] Bug An existing feature does not function as intended label Jun 24, 2024
@jorgefilipecosta jorgefilipecosta force-pushed the fix/list-view-renders-an-empty-meny-when-actions-are-not-available branch from d7d6aa5 to de84f38 Compare June 24, 2024 13:07
@jorgefilipecosta jorgefilipecosta marked this pull request as ready for review June 24, 2024 13:11
Copy link

github-actions bot commented Jun 24, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jorgefilipecosta jorgefilipecosta added the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jun 24, 2024
@ellatrix ellatrix force-pushed the fix/list-view-renders-an-empty-meny-when-actions-are-not-available branch from de84f38 to 6f530ac Compare June 25, 2024 05:07
@ellatrix ellatrix enabled auto-merge (squash) June 25, 2024 05:07
auto-merge was automatically disabled June 25, 2024 06:33

Base branch was modified

@jorgefilipecosta jorgefilipecosta merged commit e2259f6 into trunk Jun 25, 2024
60 checks passed
@jorgefilipecosta jorgefilipecosta deleted the fix/list-view-renders-an-empty-meny-when-actions-are-not-available branch June 25, 2024 07:15
@github-actions github-actions bot added this to the Gutenberg 18.7 milestone Jun 25, 2024
ellatrix added a commit that referenced this pull request Jun 25, 2024
…62786)

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
@ellatrix
Copy link
Member

I just cherry-picked this PR to the wp/6.6-rc-1 branch to get it included in the next release: bc3d7c9

@ellatrix ellatrix added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jun 25, 2024
ellatrix added a commit that referenced this pull request Jun 25, 2024
…62786)

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core [Type] Bug An existing feature does not function as intended
2 participants