Skip to content

Commit 1175bcb

Browse files
committed
More tweaks to search handling.
1 parent 0f09511 commit 1175bcb

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

js/command-palette.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
dispatch( commandsStore ).registerCommand( {
5959
name: 'user-switching/switch-off',
6060
label: settings.switchOffLabel,
61+
// This facilitates searching either in English or the localized language
6162
searchLabel: `Switch off ${ settings.switchOffLabel }`,
6263
icon: switchIcon,
6364
callback: function ( args ) {
@@ -72,9 +73,11 @@
7273
dispatch( commandsStore ).registerCommandLoader( {
7374
name: 'user-switching/switch-to-user',
7475
hook: function useSwitchToUserLoader( options ) {
76+
// This facilitates searching either in English or the localized language
77+
// and trims the search query to just the name.
7578
const trimmedSearch = options.search
7679
.replace( new RegExp( settings.switchToLabel, 'i' ), '' )
77-
.replace( /Switch To/i, '' )
80+
.replace( /Switch to/i, '' )
7881
.trim();
7982
const search = useDebouncedValue( trimmedSearch );
8083

@@ -111,10 +114,11 @@
111114
__( 'Switch to %s', 'user-switching' ),
112115
user.name,
113116
),
117+
// This facilitates searching either in English or the localized language
114118
searchLabel: sprintf(
115119
/* translators: %s: User's display name. */
116120
__( 'Switch to %s', 'user-switching' ),
117-
`${ user.name } ${ user.slug }`,
121+
`${ user.name } ${ user.slug } Switch to ${ user.name } ${ user.slug }`,
118122
),
119123
icon: avatarUrl ? el( 'img', {
120124
src: avatarUrl,

0 commit comments

Comments
 (0)