Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit 4d7a9ef

Browse files
committed
fix(hoverify): pin hover immediatly on click/jump
1 parent 41b6f25 commit 4d7a9ef

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/hoverifier.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,13 @@ export const createHoverifier = ({
371371
const hoverObservables = resolvedPositions.pipe(
372372
map(({ position, ...rest }) => {
373373
if (!position) {
374-
return of({ ...rest, hoverOrError: undefined, part: undefined })
374+
return of({ ...rest, hoverOrError: null, part: undefined })
375375
}
376376
// Fetch the hover for that position
377377
const hoverFetch = fetchHover(position).pipe(
378378
catchError(error => {
379379
if (error && error.code === EMODENOTFOUND) {
380-
return [undefined]
380+
return [null]
381381
}
382382
return [asError(error)]
383383
}),
@@ -444,7 +444,7 @@ export const createHoverifier = ({
444444
// Fetch the definition location for that position
445445
map(({ position }) => {
446446
if (!position) {
447-
return of(undefined)
447+
return of(null)
448448
}
449449
return concat(
450450
[LOADING],
@@ -497,8 +497,13 @@ export const createHoverifier = ({
497497
// and can reevaluate our pinning decision whenever one of the two updates,
498498
// independent of the order in which they emit
499499
return combineLatest(hoverObservable, definitionObservable).pipe(
500-
map(([{ hoverOrError }, definitionURLOrError]) =>
501-
overlayUIHasContent({ hoverOrError, definitionURLOrError })
500+
map(
501+
([{ hoverOrError }, definitionURLOrError]) =>
502+
// In the time between the click/jump and the loader being displayed,
503+
// pin the hover overlay so mouseover events get ignored
504+
// If the hover comes back empty (and the definition) it will get unpinned again
505+
hoverOrError === undefined ||
506+
overlayUIHasContent({ hoverOrError, definitionURLOrError })
502507
)
503508
)
504509
})

0 commit comments

Comments
 (0)