Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrongly open camera on a part of mobile browsers #20

Open
orangelle opened this issue Jul 29, 2022 · 0 comments
Open

Wrongly open camera on a part of mobile browsers #20

orangelle opened this issue Jul 29, 2022 · 0 comments

Comments

@orangelle
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

When I used the selectFiles function on the firefox or chrome browser on iPhone, I noticed that it will open the camera even if I pass false as capture prop or leave it default. After some attempts, I found that a possible solution is not to set capture attribute of input element at all.

Here is the diff that solved my problem:

diff --git a/node_modules/select-files/src/index.ts b/node_modules/select-files/src/index.ts
index 26c4d82..fd2eea9 100644
--- a/node_modules/select-files/src/index.ts
+++ b/node_modules/select-files/src/index.ts
@@ -47,7 +47,9 @@ const createInputFile = ({
 
   input.type = 'file';
   input.accept = accept;
-  input.capture = capture;
+  if (capture) {
+    input.capture = capture.toString();
+  }
   input.multiple = multiple;
 
   return input;
diff --git a/node_modules/select-files/yarn.lock b/node_modules/select-files/yarn.lock
new file mode 100644
index 0000000..6febc20
Binary files /dev/null and b/node_modules/select-files/yarn.lock differ

Hope this helps!

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant