Fix: modal dont close when user denied the camera permission on Web - #132
Open
Gkreischer wants to merge 6 commits into
Open
Fix: modal dont close when user denied the camera permission on Web#132Gkreischer wants to merge 6 commits into
Gkreischer wants to merge 6 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR improves error handling in the Web implementation of the barcode scanner.
When camera permission was denied by the user, the scanner modal could remain open and fail to close properly. Although the errors were displayed, the modal stayed visible in the interface, preventing the user from continuing to use the application.
Errors showed:
Error getting userMedia, error = NotAllowedError: Permission denied
Cannot stop, scanner is not running or paused.
This change improves the error handling flow by properly handling camera permission failures, preventing invalid scanner state operations, and allowing the modal to close correctly.
The PR also adds typed error definitions to make scanner failures easier to identify and handle by library consumers.
Change Type
Rationale / Problems Fixed
When using the Web implementation, with Ionic and Angular, denying camera permission caused an inconsistent scanner state.
The user could not properly dismiss the scanner modal, and attempting to stop the scanner after a failed
getUserMediarequest resulted in additional errors.This PR fixes this behavior by:
NotAllowedErrorfromgetUserMediaproperly.CapacitorBarcodeScannerError.This makes permission denial and other scanner failures easier for applications to handle.
Tests or Reproductions
Tested on the Web implementation.
Steps to reproduce before this change:
After this change:
Screenshots / Media
Before fix:

After fixed:

Platforms Affected
Notes / Comments
This change is intended to be backward compatible.
Existing scanner behavior remains unchanged for successful scans; this only improves failure handling and error reporting.