Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Global Search Bar] Updated placeholder text to be more directive #127903

Merged
merged 7 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

//TODO add these overrides to EUI so that search behaves the same globally (eui/issues/4363)
.kbnSearchBar {
width: 400px;
max-width: 100%;
will-change: width;
}
Expand All @@ -27,6 +26,12 @@
}
}

@include euiBreakpoint('m', 'l', 'xl') {
.kbnSearchBar {
width: 400px;
}
}

@include euiBreakpoint('l', 'xl') {
.kbnSearchBar:focus {
animation: kbnAnimateSearchBar $euiAnimSpeedFast forwards;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import useEvent from 'react-use/lib/useEvent';
import useMountedState from 'react-use/lib/useMountedState';
import { Subscription } from 'rxjs';
import {
useEuiTheme,
EuiFormLabel,
EuiHeaderSectionItemButton,
EuiIcon,
EuiSelectableTemplateSitewide,
Expand Down Expand Up @@ -69,6 +71,7 @@ export const SearchBar: FC<SearchBarProps> = ({
darkMode,
}) => {
const isMounted = useMountedState();
const { euiTheme } = useEuiTheme();
const [initialLoad, setInitialLoad] = useState(false);
const [searchValue, setSearchValue] = useState<string>('');
const [searchTerm, setSearchTerm] = useState<string>('');
Expand All @@ -77,6 +80,7 @@ export const SearchBar: FC<SearchBarProps> = ({
const searchSubscription = useRef<Subscription | null>(null);
const [options, _setOptions] = useState<EuiSelectableTemplateSitewideOption[]>([]);
const [searchableTypes, setSearchableTypes] = useState<string[]>([]);
const [showAppend, setShowAppend] = useState<boolean>(true);
const UNKNOWN_TAG_ID = '__unknown__';

useEffect(() => {
Expand Down Expand Up @@ -252,8 +256,25 @@ export const SearchBar: FC<SearchBarProps> = ({

const emptyMessage = <PopoverPlaceholder darkMode={darkMode} basePath={basePathUrl} />;
const placeholderText = i18n.translate('xpack.globalSearchBar.searchBar.placeholder', {
defaultMessage: 'Search Elastic',
defaultMessage: 'Find apps, content, and more. Ex: Discover',
});
const keyboardShortcutTooltip = `${i18n.translate(
'xpack.globalSearchBar.searchBar.shortcutTooltip.description',
{
defaultMessage: 'Keyboard shortcut',
}
)}: ${
isMac
? i18n.translate('xpack.globalSearchBar.searchBar.shortcutTooltip.macCommandDescription', {
defaultMessage: 'Command + /',
})
: i18n.translate(
'xpack.globalSearchBar.searchBar.shortcutTooltip.windowsCommandDescription',
{
defaultMessage: 'Control + /',
}
)
}`;

useEvent('keydown', onKeyDown);

Expand All @@ -277,7 +298,20 @@ export const SearchBar: FC<SearchBarProps> = ({
onFocus: () => {
trackUiMetric(METRIC_TYPE.COUNT, 'search_focus');
setInitialLoad(true);
setShowAppend(false);
},
onBlur: () => {
setShowAppend(true);
},
fullWidth: true,
append: showAppend ? (
<EuiFormLabel
title={keyboardShortcutTooltip}
css={{ fontFamily: euiTheme.font.familyCode }}
>
{isMac ? '⌘/' : '^/'}
</EuiFormLabel>
) : undefined,
}}
emptyMessage={emptyMessage}
noMatchesMessage={emptyMessage}
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -10452,7 +10452,6 @@
"xpack.globalSearchBar.searchBar.noResultsImageAlt": "Illustration d'un trou noir",
"xpack.globalSearchBar.searchBar.optionTagListAriaLabel": "Balises",
"xpack.globalSearchBar.searchbar.overflowTagsAriaLabel": "{n} {n, plural, one {balise} other {balises}} de plus : {tags}",
"xpack.globalSearchBar.searchBar.placeholder": "Rechercher dans Elastic",
"xpack.globalSearchBar.searchBar.shortcutDescription.macCommandDescription": "Commande + /",
"xpack.globalSearchBar.searchBar.shortcutDescription.shortcutDetail": "{shortcutDescription} {commandDescription}",
"xpack.globalSearchBar.searchBar.shortcutDescription.shortcutInstructionDescription": "Raccourci",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -12473,7 +12473,6 @@
"xpack.globalSearchBar.searchBar.noResultsImageAlt": "ブラックホールの図",
"xpack.globalSearchBar.searchBar.optionTagListAriaLabel": "タグ",
"xpack.globalSearchBar.searchbar.overflowTagsAriaLabel": "{n} その他の {n, plural, other {個のタグ}}:{tags}",
"xpack.globalSearchBar.searchBar.placeholder": "Elastic を検索",
"xpack.globalSearchBar.searchBar.shortcutDescription.macCommandDescription": "コマンド+ /",
"xpack.globalSearchBar.searchBar.shortcutDescription.shortcutDetail": "{shortcutDescription} {commandDescription}",
"xpack.globalSearchBar.searchBar.shortcutDescription.shortcutInstructionDescription": "ショートカット",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -12496,7 +12496,6 @@
"xpack.globalSearchBar.searchBar.noResultsImageAlt": "黑洞的图示",
"xpack.globalSearchBar.searchBar.optionTagListAriaLabel": "标签",
"xpack.globalSearchBar.searchbar.overflowTagsAriaLabel": "另外 {n} 个{n, plural, other {标签}}:{tags}",
"xpack.globalSearchBar.searchBar.placeholder": "搜索 Elastic",
"xpack.globalSearchBar.searchBar.shortcutDescription.macCommandDescription": "Command + /",
"xpack.globalSearchBar.searchBar.shortcutDescription.shortcutDetail": "{shortcutDescription} {commandDescription}",
"xpack.globalSearchBar.searchBar.shortcutDescription.shortcutInstructionDescription": "快捷方式",
Expand Down