Wunderbar: fix popup dismissed despite a child is in focus
## Issue 1. Type something in the wunderbar. 2. While the spinner is running, press Tab to focus on "View results" button. 3. If the spinner is still running, the entire popup gets dismissed (it should not). If the spinner isn't running, the popup stays active. ## Change It was explicitly dismissed when the <input> loses focus. It shouldn't do that if any child of the popup is in focus.
This commit is contained in:
parent
939d26801a
commit
9d1ff4e8ae
1 changed files with 7 additions and 3 deletions
|
@ -64,7 +64,11 @@ export default function WunderBarSuggestions(props: Props) {
|
|||
customSelectAction,
|
||||
} = props;
|
||||
const inputRef: ElementRef<any> = React.useRef();
|
||||
const isFocused = inputRef && inputRef.current && inputRef.current === document.activeElement;
|
||||
const viewResultsRef: ElementRef<any> = React.useRef();
|
||||
const exploreTagRef: ElementRef<any> = React.useRef();
|
||||
|
||||
const isRefFocused = (ref) => ref && ref.current && ref.current === document.activeElement;
|
||||
const isFocused = isRefFocused(inputRef) || isRefFocused(viewResultsRef) || isRefFocused(exploreTagRef);
|
||||
|
||||
const {
|
||||
push,
|
||||
|
@ -324,10 +328,10 @@ export default function WunderBarSuggestions(props: Props) {
|
|||
{!noBottomLinks && (
|
||||
<div className="wunderbar__bottom-links">
|
||||
<ComboboxOption value={term} className="wunderbar__more-results">
|
||||
<Button button="link" label={__('View All Results')} />
|
||||
<Button ref={viewResultsRef} button="link" label={__('View All Results')} />
|
||||
</ComboboxOption>
|
||||
<ComboboxOption value={`${TAG_SEARCH_PREFIX}${term}`} className="wunderbar__more-results">
|
||||
<Button className="wunderbar__tag-search" button="link">
|
||||
<Button ref={exploreTagRef} className="wunderbar__tag-search" button="link">
|
||||
{__('Explore')}
|
||||
<div className="tag">{term.split(' ').join('')}</div>
|
||||
</Button>
|
||||
|
|
Loading…
Reference in a new issue