From 26c64bf040a6cea34402c74dc619f0910d16c5ee Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 22 May 2025 13:53:43 +0800 Subject: [PATCH] fix(ux): remove highlight boundary when using mouse Signed-off-by: Innei --- .../EntryColumnShortcutHandler.tsx | 13 ++++++--- .../modules/entry-content/index.electron.tsx | 27 +++++++++++-------- .../timeline-column/FeedList.electron.tsx | 10 ++++--- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/apps/desktop/layer/renderer/src/modules/entry-column/EntryColumnShortcutHandler.tsx b/apps/desktop/layer/renderer/src/modules/entry-column/EntryColumnShortcutHandler.tsx index c2b296c8b..1eea878f6 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-column/EntryColumnShortcutHandler.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-column/EntryColumnShortcutHandler.tsx @@ -100,10 +100,15 @@ export const EntryColumnShortcutHandler: FC<{ const $scrollArea = useScrollViewElement() const { highlightBoundary } = useFocusActions() useEffect(() => { - return EventBus.subscribe(COMMAND_ID.layout.focusToTimeline, () => { - $scrollArea?.focus() - nextFrame(highlightBoundary) - }) + return EventBus.subscribe( + COMMAND_ID.layout.focusToTimeline, + ({ highlightBoundary: highlight }) => { + $scrollArea?.focus() + if (highlight) { + nextFrame(highlightBoundary) + } + }, + ) }, [$scrollArea, highlightBoundary]) const isFocusIn = useFocusable() diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/index.electron.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/index.electron.tsx index ab29edd3e..554100f18 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/index.electron.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/index.electron.tsx @@ -104,7 +104,7 @@ export const EntryContent: Component = ({ useEffect(() => { if (prevEntryId.current !== entryId) { - springScrollTo(0, scrollerRef.current!) + scrollerRef.current?.scrollTo({ top: 0 }) animationController.start(pageMotionVariants.exit).then(() => { animationController.start(pageMotionVariants.animate) }) @@ -412,16 +412,21 @@ const RegisterCommands = ({ } checkScrollBottom($scroller) }), - EventBus.subscribe(COMMAND_ID.layout.focusToEntryRender, () => { - const $scroller = scrollerRef.current - if (!$scroller) { - return - } - springScrollTo(0, $scroller) - $scroller.focus() - nextFrame(highlightBoundary) - setIsUserInteraction(true) - }), + EventBus.subscribe( + COMMAND_ID.layout.focusToEntryRender, + ({ highlightBoundary: highlight }) => { + const $scroller = scrollerRef.current + if (!$scroller) { + return + } + springScrollTo(0, $scroller) + $scroller.focus() + if (highlight) { + nextFrame(highlightBoundary) + } + setIsUserInteraction(true) + }, + ), ) }, [highlightBoundary, scrollerRef, setIsUserInteraction]) diff --git a/apps/desktop/layer/renderer/src/modules/timeline-column/FeedList.electron.tsx b/apps/desktop/layer/renderer/src/modules/timeline-column/FeedList.electron.tsx index 464a20e12..fd3c6a4e9 100644 --- a/apps/desktop/layer/renderer/src/modules/timeline-column/FeedList.electron.tsx +++ b/apps/desktop/layer/renderer/src/modules/timeline-column/FeedList.electron.tsx @@ -379,11 +379,13 @@ const useRegisterCommand = () => { EventBus.subscribe(COMMAND_ID.subscription.previousSubscription, () => { handleSubscriptionNavigation("previous") }), - EventBus.subscribe(COMMAND_ID.layout.focusToSubscription, () => { + EventBus.subscribe(COMMAND_ID.layout.focusToSubscription, ({ highlightBoundary }) => { focusableContainerRef.current?.focus() - nextFrame(() => { - focusActions.highlightBoundary() - }) + if (highlightBoundary) { + nextFrame(() => { + focusActions.highlightBoundary() + }) + } }), EventBus.subscribe(COMMAND_ID.subscription.toggleFolderCollapse, () => { const result = getCurrentActiveSubscriptionElement()