fix: auto-navigate to product form after barcode scan#4
Conversation
After scanning a barcode, the app now automatically navigates to the "Add Product" form with scanned data (name, barcode) pre-filled. This eliminates the intermediate card that kept jumping/flickering due to multiple scan callbacks, making the flow much smoother. https://claude.ai/code/session_018567acDi8JQ3BHH8BxYX5b
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f905645b2f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const product = await lookupBarcode(barcode); | ||
| if (product) { | ||
| setState({ | ||
| type: 'found', | ||
| barcode, | ||
| name: product.name, | ||
| imageUrl: product.imageUrl, | ||
| }); | ||
| } else { | ||
| setState({ type: 'not_found', barcode }); | ||
| } | ||
| // Navigate to form with whatever data we got | ||
| navigateToAddWithScan({ |
There was a problem hiding this comment.
Cancel pending lookup before forcing page navigation
After a scan succeeds, this callback always calls navigateToAddWithScan when lookupBarcode resolves, even if the user has already left the scanner (e.g., via the bottom navigation while the loading state is visible). In that case the delayed async completion will unexpectedly yank them back to the add form, which is a regression from the previous local-state-only flow; guard this with an unmounted/cancelled flag before navigating.
Useful? React with 👍 / 👎.
After scanning a barcode, the app now automatically navigates to the "Add Product" form with scanned data (name, barcode) pre-filled. This eliminates the intermediate card that kept jumping/flickering due to multiple scan callbacks, making the flow much smoother.
https://claude.ai/code/session_018567acDi8JQ3BHH8BxYX5b