Skip to content

Archives block Drop-down issue #70508

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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

shubhtoy
Copy link

What?

Closes #13771

Fix Archives block dropdown functionality by making it interactive in the editor and functional on the frontend, aligning with the Category block behavior.

Why?

The Archives block's "Display as Drop-down" option was not working properly. When users selected this option, the dropdown was rendered but was disabled and non-functional. This created a poor user experience and accessibility issues, as the dropdown appeared to be broken rather than clearly indicating its disabled state.

As discussed in issue #13771, the ideal solution is to make archive blocks work like category blocks - being both accessible and using the same interaction patterns for consistency across the editor.

How?

The implementation includes two main changes:

  1. Editor Changes (packages/block-library/src/archives/edit.js):

    • Removed the Disabled wrapper around the ServerSideRender component
    • Removed unused Disabled import
    • This allows the dropdown to be interactive in the editor, matching the behavior of the Category block
  2. Frontend Changes (packages/block-library/src/archives/index.php):

    • Removed the inline onchange attribute from the select element
    • Added a new function build_dropdown_script_block_core_archives() that generates proper JavaScript for dropdown functionality
    • The script is only injected on the frontend (not in admin), ensuring the dropdown works correctly when the post is published
    • Used wp_get_inline_script_tag() for proper script injection following WordPress standards

Testing Instructions

  1. Open a post or page in the editor
  2. Insert an Archives block
  3. In the block settings panel, check "Display as Drop-down"
  4. Verify that the dropdown is now interactive in the editor (you can click on it)
  5. Save and view the post on the frontend
  6. Click on the dropdown and select an archive date
  7. Verify that the page redirects to the selected archive

Screenshots or screencast

The dropdown now functions consistently between editor and frontend, matching the Category block behavior for improved user experience

Before

Screen.Recording.2025-06-24.at.2.49.55.PM.mov

After

Screen.Recording.2025-06-24.at.2.53.20.PM.mov

@shubhtoy shubhtoy changed the title Fix/archive block dropdown Archives block Drop-down issue Jun 24, 2025
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @shubhtoy! 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.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jun 24, 2025
@shubhtoy shubhtoy marked this pull request as ready for review June 25, 2025 08:42
Copy link

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @bemdesign-er, @mapk.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: bemdesign-er, mapk.

Co-authored-by: shubhtoy <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: utsavtilava <[email protected]>

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

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Archives Affects the Archives Block labels Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Archives Affects the Archives Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Archives block Drop-down issue
2 participants