WordPress.org

Make WordPress Core

Opened 18 months ago

Closed 17 months ago

Last modified 17 months ago

#47609 closed defect (bug) (invalid)

Archive widget has stopped working.

Reported by: EXL Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.2.2
Component: Widgets Keywords:
Focuses: Cc:

Description

When I choose a month nothing happens.

In previous versions of WordPress, <select> form was filled with the onchange property:

<select id="archives-dropdown-2" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">

This worked perfectly.

Now JavaScript function is being used, which seems to work incorrect in my WordPress installation:

<script type="text/javascript">
/* <![CDATA[ */
(function() {
	var dropdown = document.getElementById( "archives-dropdown-3" );
	function onSelectChange() {
		if ( dropdown.options[ dropdown.selectedIndex ].value !== '' ) {
			document.location.href = this.options[ this.selectedIndex ].value;
		}
	}
	dropdown.onchange = onSelectChange;
})();
/* ]]> */
</script>

Most likely this bug was introduced in this commit: https://github.com/WordPress/WordPress/commit/bba488f2b7fc241b03063fefc58a1db479e977d6#diff-f1b15459db03501d704506f19d778693R107

P.S. I use these settings:

http://esxi.z-lab.me:666/~exl_lab/screens/WordPress_Archive_Widget_Settings.png

Attachments (1)

WordPress_Archive_Widget_Settings.png (10.0 KB) - added by EXL 18 months ago.
WordPress Archive Widget Settings

Download all attachments as: .zip

Change History (5)

@EXL
18 months ago

WordPress Archive Widget Settings

#2 @SergeyBiryukov
17 months ago

  • Keywords reporter-feedback added

Hi @EXL, welcome to WordPress Trac! Thanks for the report.

Looks like there is a mismatch between archives-dropdown-2 in the older code and archives-dropdown-3 in the newer function, however I could not reproduce the issue on a clean install.

After creating two Archives widgets on the same page (getting archives-dropdown-2 and archives-dropdown-3 ID attributes, respectively), choosing a month in either of them work as expected for me. Tested with the latest stable versions of Google Chrome and Microsoft Edge.

  1. Which browser are you using?
  2. Could you provide the steps to reproduce the issue on a clean install?
  3. Do you have a live page example where the widget doesn't work as expected?
  4. Does the similar JS code in the Categories widget work for you?
Last edited 17 months ago by SergeyBiryukov (previous) (diff)

#3 @EXL
17 months ago

  • Resolution set to invalid
  • Status changed from new to closed

@SergeyBiryukov
I'm sorry. The error was found in my own template.

#4 @SergeyBiryukov
17 months ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted

No worries, thanks for the follow-up.

Note: See TracTickets for help on using tickets.