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

DataViews table layout: hide actions menu when there is only one action and is primary #67020

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

oandregal
Copy link
Member

Part of #65165

What?

This PR hides the actions menu for the DataViews table layout when there's only 1 action and is primary.

Before After
Screenshot 2024-11-15 at 08 00 30 Screenshot 2024-11-15 at 08 00 54

All current core screens have more than one action. See testing instructions below.

Why?

To improve UX.

Testing Instructions

This is something we've heard from extenders. Because there's no place in core where we have this situation just yet, we have to create one for testing:

  • Go to the post-list code and remove the postTypeActions in this line and in the line below (in both arrays).
  • Visit the Pages page and switch to the table layout.
  • Verify the actions menu is hidden, only the edit icon is displayed.

@oandregal oandregal self-assigned this Nov 15, 2024
Copy link

github-actions bot commented Nov 15, 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: oandregal <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: ntsekouras <[email protected]>

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

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised ✅

primaryActions: Action< Item >[],
actions: Action< Item >[]
) {
return primaryActions.length === 1 && actions.length;
Copy link
Contributor

@ntsekouras ntsekouras Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not inline the check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could work as well. No big feelings either way. I suppose I thought it better to have it explain the why.

@ntsekouras
Copy link
Contributor

Noting that we do this for every layout and not only for table. We should update the title.

I was a bit confused that list layout doesn't use these action components. It seems probably about adding some extra things for keyboard navigation and I'm wondering if we can absorb that somehow.

@oandregal
Copy link
Member Author

Noting that we do this for every layout and not only for table. We should update the title.

This is actually only for the table. Here's the PR for the list #67015 :)

The list view uses the subcomponents directly to handle the keyboard interactions. The grid is unaffected because it uses the compact view (no primary actions visible). This can be tested by switching to any other layout during testing.

List Grid Table
Screenshot 2024-11-15 at 09 28 18 Screenshot 2024-11-15 at 09 28 09 Screenshot 2024-11-15 at 09 28 02

@oandregal oandregal merged commit 40954ff into trunk Nov 15, 2024
80 checks passed
@oandregal oandregal deleted the hide/actions-menu-table branch November 15, 2024 08:32
@github-actions github-actions bot added this to the Gutenberg 19.8 milestone Nov 15, 2024
@ntsekouras
Copy link
Contributor

The list view uses the subcomponents directly to handle the keyboard interactions. The grid is unaffected because it uses the compact view (no primary actions visible). This can be tested by switching to any other layout during testing.

Exactly. If grid wasn't using the compact and had one primary action would have the same behavior. For now it doesn't, but when we open the API for registering layouts, this behavior will be for any layout.

@oandregal
Copy link
Member Author

@ntsekouras Agreed. If things worked differently then yes, it'd make sense to change the changelog/issue title to be about all the layouts. I just worry that it'd be confusing to say so when it's not true right now? Not sure how it could be improved without being confusing, but happy to explore alternatives if you have any suggestion.

@ntsekouras
Copy link
Contributor

The title is not that important right now, yes. We should keep this in mind when creating the API for layouts to document it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] DataViews /packages/dataviews [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants