From 5187ad5113c470873870a9a53270437a00a3bdce Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 20 Apr 2022 08:58:51 -0700 Subject: [PATCH 1/2] Return focus to item after setting its labels --- .../templates/homeFeed/HomeFeedContainer.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx index 993776ba1..8a4d47a86 100644 --- a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx +++ b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx @@ -430,6 +430,9 @@ export function HomeFeedContainer(props: HomeFeedContainerProps): JSX.Element { setLabelsTarget={setLabelsTarget} showAddLinkModal={showAddLinkModal} setShowAddLinkModal={setShowAddLinkModal} + setActiveItem={(item: LibraryItem) => { + activateCard(item.node.id) + }} /> ) } @@ -452,6 +455,7 @@ type HomeFeedContentProps = { setLabelsTarget: (target: LibraryItem | undefined) => void showAddLinkModal: boolean setShowAddLinkModal: (show: boolean) => void + setActiveItem: (item: LibraryItem) => void actionHandler: ( action: LinkedItemCardAction, item: LibraryItem | undefined @@ -745,7 +749,11 @@ function HomeFeedGrid(props: HomeFeedContentProps): JSX.Element { } }} onOpenChange={() => { - props.setLabelsTarget(undefined) + if (props.labelsTarget) { + const activate = props.labelsTarget + props.setActiveItem(activate) + props.setLabelsTarget(undefined) + } }} /> )} From 92423eaa0da60d17f5bce5ae6e7be54257b8b25c Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 20 Apr 2022 09:33:25 -0700 Subject: [PATCH 2/2] Disable keyboard navigation if a modal is open in the library --- .../templates/homeFeed/HomeFeedContainer.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx index 8a4d47a86..4ec5db90b 100644 --- a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx +++ b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx @@ -236,14 +236,8 @@ export function HomeFeedContainer(props: HomeFeedContainerProps): JSX.Element { return } - // If any of the modals are open we disable handling keyboard shortcuts - if (labelsTarget || snoozeTarget || shareTarget) { - return - } - switch (action) { case 'showDetail': - const username = viewerData?.me?.profile.username if (username) { setActiveCardId(item.node.id) @@ -293,6 +287,11 @@ export function HomeFeedContainer(props: HomeFeedContainerProps): JSX.Element { return gridColumnCount } + // If any of the modals are open we disable handling keyboard shortcuts + if (labelsTarget || snoozeTarget || shareTarget) { + return + } + switch (action) { case 'openArticle': handleCardAction('showDetail', activeItem)