WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.18k forks source link

Fix set current category as default selected item in category list dr… #66668

Open calvinrodrigues500 opened 1 day ago

calvinrodrigues500 commented 1 day ago

What?

Category List Block: Set current category as the default selected item in dropdown Fixes #66613

When the Category List block is added to a category archive template in Gutenberg, the dropdown displays "Select Category" by default on archive pages, even though a specific category is being viewed. Ideally, the dropdown should show the active category as the selected item.

Why?

This improvement enhances user experience by reducing confusion and making navigation clearer. Displaying the active category reinforces context for users on archive pages and aligns with expected dropdown behavior.

How?

This PR updates the Category List block to detect the current category when used on a category archive template. By setting the active category as the default selected item in the dropdown, it aligns the block’s behavior with user expectations on archive pages. This change ensures that when users view a category archive, the dropdown automatically reflects the category they are currently browsing,

Testing Instructions

  1. Go to the Site Editor and open the template for Category Archives and add a Category List Block.
  2. In the block settings, set it to Display as Dropdown.
  3. Preview the Archive Page and verify the dropdown selection.
  4. From the WordPress admin dashboard, go to Posts > Categories and view individual category archive pages to confirm each one displays the respective category as the default selection in the dropdown.

Testing Instructions for Keyboard

Screenshots or screencast

Screencast from 01-11-24 12:29:32 PM IST.webm

github-actions[bot] commented 1 day ago

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

github-actions[bot] commented 1 day ago

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: calvinrodrigues500 <calvinrodrigues@git.wordpress.org>
Co-authored-by: bradhogan <bradley2083@git.wordpress.org>

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

github-actions[bot] commented 1 day ago

:wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @calvinrodrigues500! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.