mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 09:36:17 +08:00
fix: close peek view when clicking on reference link (#7137)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta';
|
||||
import { useJournalHelper } from '@affine/core/hooks/use-journal';
|
||||
import { PeekViewService } from '@affine/core/modules/peek-view';
|
||||
import {
|
||||
PeekViewService,
|
||||
useInsidePeekView,
|
||||
} from '@affine/core/modules/peek-view';
|
||||
import { WorkbenchLink } from '@affine/core/modules/workbench';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { LinkedPageIcon, TodayIcon } from '@blocksuite/icons';
|
||||
@@ -69,6 +72,7 @@ export function AffinePageReference({
|
||||
const ref = useRef<HTMLAnchorElement>(null);
|
||||
|
||||
const peekView = useService(PeekViewService).peekView;
|
||||
const isInPeekView = useInsidePeekView();
|
||||
|
||||
const onClick = useCallback(
|
||||
(e: React.MouseEvent) => {
|
||||
@@ -76,11 +80,14 @@ export function AffinePageReference({
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
peekView.open(ref.current);
|
||||
return true; // means this click is handled
|
||||
return false; // means this click is handled
|
||||
}
|
||||
return false;
|
||||
if (isInPeekView) {
|
||||
peekView.close();
|
||||
}
|
||||
return;
|
||||
},
|
||||
[peekView]
|
||||
[isInPeekView, peekView]
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -287,7 +287,7 @@ function PageListItemWrapper({
|
||||
const handleClick = useCallback(
|
||||
(e: React.MouseEvent) => {
|
||||
if (!selectionState.selectable) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
stopPropagation(e);
|
||||
const currentIndex = pageIds.indexOf(pageId);
|
||||
@@ -297,15 +297,15 @@ function PageListItemWrapper({
|
||||
setSelectionActive(true);
|
||||
setAnchorIndex(currentIndex);
|
||||
onClick?.();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
handleShiftClick(currentIndex);
|
||||
return true;
|
||||
return false;
|
||||
} else {
|
||||
setAnchorIndex(undefined);
|
||||
setRangeIds([]);
|
||||
onClick?.();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
},
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user