Conditionally render search placeholder text (#450)

Placeholder text was appearing cropped in menuWidth = 'narrow' 
This commit serves to conditionally render placeholder text to a shorter 'Search'

Bug: https://phabricator.wikimedia.org/T318633
This commit is contained in:
wangombe-g
2023-03-22 17:20:01 +03:00
committed by GitHub
parent 92aa012bc7
commit 9eddca7d53
3 changed files with 9 additions and 3 deletions

View File

@@ -18,5 +18,6 @@
"uls-common-languages": "Suggested languages", "uls-common-languages": "Suggested languages",
"uls-no-results-suggestion-title": "You may be interested in:", "uls-no-results-suggestion-title": "You may be interested in:",
"uls-search-help": "You can search by language name, script name, ISO code of language or you can browse by region.", "uls-search-help": "You can search by language name, script name, ISO code of language or you can browse by region.",
"uls-search-placeholder": "Search for a language" "uls-search-placeholder": "Search for a language",
"uls-search-placeholder-short": "Search"
} }

View File

@@ -19,5 +19,6 @@
"uls-common-languages": "The ULS tries to guess the langugages that the user is most likely to pick. They are taken from geolocation (languages of the current country according to the IP address), previously selected languages, and the browser's accept-language. The list of these languages appears at the top of the ULS languages list, above the geographical regions. This is the title of that list.\n\nSee also {{msg-mw|Mobile-frontend-languages-structured-overlay-suggested-languages-header}}", "uls-common-languages": "The ULS tries to guess the langugages that the user is most likely to pick. They are taken from geolocation (languages of the current country according to the IP address), previously selected languages, and the browser's accept-language. The list of these languages appears at the top of the ULS languages list, above the geographical regions. This is the title of that list.\n\nSee also {{msg-mw|Mobile-frontend-languages-structured-overlay-suggested-languages-header}}",
"uls-no-results-suggestion-title": "Title for language suggestion in 'no results found' screen", "uls-no-results-suggestion-title": "Title for language suggestion in 'no results found' screen",
"uls-search-help": "Help text for searching.\n\n\"Script name\" is a name of a writing system, such as \"Latin\", \"Cyrillic\", \"Arabic\" etc.", "uls-search-help": "Help text for searching.\n\n\"Script name\" is a name of a writing system, such as \"Latin\", \"Cyrillic\", \"Arabic\" etc.",
"uls-search-placeholder": "Placeholder text in search box" "uls-search-placeholder": "Placeholder text in search box",
"uls-search-placeholder-short": "Shorter placeholder text in search box when menu width is narrow"
} }

View File

@@ -174,8 +174,12 @@
i18n: function () { i18n: function () {
if ( $.i18n ) { if ( $.i18n ) {
this.$menu.find( '[data-i18n]' ).i18n(); this.$menu.find( '[data-i18n]' ).i18n();
if ( this.getMenuWidth() === 'narrow' ) {
this.$languageFilter.prop( 'placeholder', $.i18n( 'uls-search-placeholder-short' ) );
} else {
this.$languageFilter.prop( 'placeholder', $.i18n( 'uls-search-placeholder' ) ); this.$languageFilter.prop( 'placeholder', $.i18n( 'uls-search-placeholder' ) );
} }
}
}, },
/** /**