Explorar el Código

fix: adding check for link length to prevent early return (#4982)

Co-authored-by: Connor Hanafee <connorp@Connors-MacBook-Pro.local>
Co-authored-by: dwelle <luzar.david@gmail.com>
connorhanafee hace 3 años
padre
commit
580e719580
Se han modificado 2 ficheros con 7 adiciones y 4 borrados
  1. 4 4
      src/components/App.tsx
  2. 3 0
      src/element/Hyperlink.tsx

+ 4 - 4
src/components/App.tsx

@@ -2409,13 +2409,13 @@ class App extends React.Component<AppProps, AppState> {
       }
       return (
         element.link &&
+        index <= hitElementIndex &&
         isPointHittingLinkIcon(
           element,
           this.state,
           [scenePointer.x, scenePointer.y],
           this.deviceType.isMobile,
-        ) &&
-        index <= hitElementIndex
+        )
       );
     });
   };
@@ -2443,7 +2443,7 @@ class App extends React.Component<AppProps, AppState> {
       this.state,
     );
     const lastPointerDownHittingLinkIcon = isPointHittingLinkIcon(
-      this.hitLinkElement!,
+      this.hitLinkElement,
       this.state,
       [lastPointerDownCoords.x, lastPointerDownCoords.y],
       this.deviceType.isMobile,
@@ -2453,7 +2453,7 @@ class App extends React.Component<AppProps, AppState> {
       this.state,
     );
     const lastPointerUpHittingLinkIcon = isPointHittingLinkIcon(
-      this.hitLinkElement!,
+      this.hitLinkElement,
       this.state,
       [lastPointerUpCoords.x, lastPointerUpCoords.y],
       this.deviceType.isMobile,

+ 3 - 0
src/element/Hyperlink.tsx

@@ -337,6 +337,9 @@ export const isPointHittingLinkIcon = (
   [x, y]: Point,
   isMobile: boolean,
 ) => {
+  if (!element.link || appState.selectedElementIds[element.id]) {
+    return false;
+  }
   const threshold = 4 / appState.zoom.value;
   if (
     !isMobile &&