JaredReisinger / react-crossword

A flexible, responsive, and easy-to-use crossword component for React apps.
https://react-crossword.jaredreisinger.com
MIT License
168 stars 80 forks source link

Call onClueSelected on click of cell and input to know the clue #554

Open RJBernardo opened 11 months ago

RJBernardo commented 11 months ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @jaredreisinger/react-crossword@5.2.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@jaredreisinger/react-crossword/dist/CrosswordProvider.js b/node_modules/@jaredreisinger/react-crossword/dist/CrosswordProvider.js
index 8165e51..e55772a 100644
--- a/node_modules/@jaredreisinger/react-crossword/dist/CrosswordProvider.js
+++ b/node_modules/@jaredreisinger/react-crossword/dist/CrosswordProvider.js
@@ -561,6 +561,9 @@ const CrosswordProvider = react_1.default.forwardRef(({ data, theme, onAnswerCom
                 direction = other;
             }
             setCurrentNumber((_a = cellData[direction]) !== null && _a !== void 0 ? _a : '');
+            if (onClueSelected) {
+                onClueSelected(direction, cellData[direction] ?? '');
+            }
         }
         focus();
     }, [currentDirection, focus, focused, focusedCol, focusedRow]);
diff --git a/node_modules/@jaredreisinger/react-crossword/src/CrosswordProvider.tsx b/node_modules/@jaredreisinger/react-crossword/src/CrosswordProvider.tsx
index 8d8633c..2ad68a5 100644
--- a/node_modules/@jaredreisinger/react-crossword/src/CrosswordProvider.tsx
+++ b/node_modules/@jaredreisinger/react-crossword/src/CrosswordProvider.tsx
@@ -886,6 +886,9 @@ const CrosswordProvider = React.forwardRef<
           }

           setCurrentNumber(cellData[direction] ?? '');
+          if (onClueSelected) {
+            onClueSelected(direction, cellData[direction] ?? '');
+          }
         }

         focus();

This issue body was partially generated by patch-package.