Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fixed keyboard shortcut bug

Steven Tey9aaf132e3d63
diff --git a/components/app/links/link-card.tsx b/components/app/links/link-card.tsx
index 071efde118..509ea054f0 100644
--- a/components/app/links/link-card.tsx
+++ b/components/app/links/link-card.tsx
@@ -98,10 +98,13 @@ export default function LinkCard({ props }: { props: LinkProps }) {
// do this via event listener
const onClick = (e: any) => {
- if (linkRef.current && !linkRef.current.contains(e.target)) {
- setSelected(false);
- } else {
- setSelected(!selected);
+ const existingModalBackdrop = document.getElementById("modal-backdrop");
+ if (!existingModalBackdrop) {
+ if (linkRef.current && !linkRef.current.contains(e.target)) {
+ setSelected(false);
+ } else {
+ setSelected(!selected);
+ }
}
};
@@ -109,7 +112,7 @@ export default function LinkCard({ props }: { props: LinkProps }) {
const onKeyDown = (e: any) => {
// only run shortcut logic if link is selected or the 3 dots menu is open
if ((selected || openPopover) && shortcuts.includes(e.key)) {
- setOpenPopover(false);
+ setSelected(false);
switch (e.key) {
case "e":
setShowAddEditLinkModal(true);
@@ -134,7 +137,7 @@ export default function LinkCard({ props }: { props: LinkProps }) {
document.removeEventListener("click", onClick);
document.removeEventListener("keydown", onKeyDown);
};
- }, [onClick]);
+ }, [onClick, onKeyDown]);
return (
<div
diff --git a/posts/changelog/keyboard-shortcuts.mdx b/posts/changelog/keyboard-shortcuts.mdx
index 94d7866ddc..cc19a9334f 100644
--- a/posts/changelog/keyboard-shortcuts.mdx
+++ b/posts/changelog/keyboard-shortcuts.mdx
@@ -1,6 +1,6 @@
---
title: Keyboard shortcuts
-publishedAt: 2023-05-01
+publishedAt: 2023-05-02
summary: "Introducing keyboard shortcuts on Dub"
image: "https://d2vwwcvoksz7ty.cloudfront.net/changelog/keyboard-shortcuts.png"
author: "steventey"