jquery.suggestions: Load initial suggestions only when focused
authorFomafix <fomafix@googlemail.com>
Wed, 5 Jun 2019 06:01:36 +0000 (08:01 +0200)
committerFomafix <fomafix@googlemail.com>
Mon, 10 Jun 2019 13:41:47 +0000 (15:41 +0200)
Firefox restores the value of the search field on browser history back
on some special pages with OOUI search suggestions. In this case the
value of the search field gets also changed before JavaScript gets
initialized and the search suggestions get loaded.

This change loads the initial suggestions only when the search field is
focused and the value is changed before initializing JavaScript.

Bug: T224952
Change-Id: I30d334ae61b40666f14c2b6f82fe7f66ebc8fba0

resources/src/jquery/jquery.suggestions.js

index 25f57ef..7b10149 100644 (file)
                                        } );
                                // Load suggestions if the value is changed because there are already
                                // typed characters before the JavaScript is loaded.
-                               if ( this.value !== this.defaultValue ) {
+                               if ( $( this ).is( ':focus' ) && this.value !== this.defaultValue ) {
                                        update( context, false );
                                }
                        }