mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
feat: hide command bar when losing focus (#7544)
This commit is contained in:
parent
cad8a3c2df
commit
51a2b3aa0e
@ -213,6 +213,16 @@ export const CommandBar = () => {
|
||||
searchInputRef.current?.focus();
|
||||
}
|
||||
};
|
||||
|
||||
const onBlur = (evt: React.FocusEvent) => {
|
||||
if (
|
||||
evt.relatedTarget === null ||
|
||||
!searchContainerRef.current?.contains(evt.relatedTarget)
|
||||
) {
|
||||
hideSuggestions();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledContainer ref={searchContainerRef} active={showSuggestions}>
|
||||
<RecentlyVisitedRecorder />
|
||||
@ -279,7 +289,10 @@ export const CommandBar = () => {
|
||||
<ConditionallyRender
|
||||
condition={Boolean(value) && showSuggestions}
|
||||
show={
|
||||
<CommandResultsPaper onKeyDownCapture={onKeyDown}>
|
||||
<CommandResultsPaper
|
||||
onKeyDownCapture={onKeyDown}
|
||||
onBlur={onBlur}
|
||||
>
|
||||
{searchString !== undefined && (
|
||||
<CommandSearchFeatures
|
||||
searchString={searchString}
|
||||
@ -309,7 +322,10 @@ export const CommandBar = () => {
|
||||
}
|
||||
elseShow={
|
||||
showSuggestions && (
|
||||
<CommandResultsPaper onKeyDownCapture={onKeyDown}>
|
||||
<CommandResultsPaper
|
||||
onKeyDownCapture={onKeyDown}
|
||||
onBlur={onBlur}
|
||||
>
|
||||
<CommandQuickSuggestions
|
||||
routes={allRoutes}
|
||||
onClick={clearSearchValue}
|
||||
|
Loading…
Reference in New Issue
Block a user