Page MenuHomePhabricator

On some special pages the search suggestions get shown on browser history back
Closed, ResolvedPublicBUG REPORT

Description

Steps to Reproduce:

  • Load Special:Search or Special:ComparePages or Special:Preferences or Special:Newpages
  • Select the general search field, enter some characters and select an article from the search suggestions.
  • -> The new page gets loaded.
  • Activate the history back function in the browser. -> The previous special page gets loaded again.

Actual Results:

  • The search field contains already the previous selected article and the search suggestions get shown.

Expected Results:

Only some special pages are affected by this strange behavior. It is probably related to special pages using OOUI.
Not affected special pages:

  • Special:Diff
  • Special:RecentChanges

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I don't think the search field has to be cleared. The filled search field was normal behaviour in prior software versions. Only the search suggestions should not be shown.

Hmm, I see. Before rMW72f61f7a5930 on browser history back there was never a search suggestion window but only on some special pages the search input field gets restored and on other special pages not. Now when the search input field gets restored then additionally the search suggestion field gets shown.

Fomafix renamed this task from On some special pages the search suggestions get shown on browser histrory back to On some special pages the search suggestions get shown on browser history back.Jun 4 2019, 8:57 AM
Fomafix updated the task description. (Show Details)

This part in OOUI causes the restore of the value in the OOUI search input field on Special:Search: https://gerrit.wikimedia.org/g/oojs/ui/+/98dc3e15db7b699f14a1a6277da0d20c0edc554f/src/widgets/TextInputWidget.js#110

		this.$input.attr( 'autocomplete', 'off' );
		// Turning off autocompletion also disables "form caching" when the user navigates to a
		// different page and then clicks "Back". Re-enable it when leaving.
		// Borrowed from jQuery UI.
		$( window ).on( {
			beforeunload: function () {
				this.$input.removeAttr( 'autocomplete' );
			}.bind( this ),
			pageshow: function () {
				// Browsers don't seem to actually fire this event on "Back", they instead just
				// reload the whole page... it shouldn't hurt, though.
				this.$input.attr( 'autocomplete', 'off' );
			}.bind( this )
		} );

In Firefox this also restores the general search field value. Other browser don't restore the value of the general search field on history back.

Even an empty function restores the search field value in Firefox:

$( window ).on( 'beforeunload', function () {} );

Strange.

Change 514422 had a related patch set uploaded (by Fomafix; owner: Fomafix):
[mediawiki/core@master] jquery.suggestions: Load initial suggestions only when focused

https://gerrit.wikimedia.org/r/514422

@Formatierer: With https://gerrit.wikimedia.org/r/514422 the search suggestion gets only loaded when the input field is focused. This should still hit the case when there are type characters in the input field but avoid the case when the value of the input field is restored by browser history back because then the input field is normally not focused.

https://gerrit.wikimedia.org/r/514422 does not change the behavior of the input field itself. On Firefox on some special pages the value of the general search input field gets restored on browser history back.

Change 514422 merged by jenkins-bot:
[mediawiki/core@master] jquery.suggestions: Load initial suggestions only when focused

https://gerrit.wikimedia.org/r/514422

matmarex removed a project: Patch-For-Review.
matmarex subscribed.

@Fomafix Thank you for following up on this! I'm sorry I didn't have time earlier to look at this patch (or your other jquery.suggestions patches).

There are apparently no scheduled deployments this week (due to SRE team meeting), so the fix will only be deployed next week, 18-20 June, per the usual schedule.

I updated the description to match the change. Only the search suggestion field on browser history back is a regression.

In Firefox the inconsistency in restoring the value of the input fields on browser history back depending on the special page still exist.