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

input nwdirectory makes a wrong path when openning the path selector dialog again #7786

Open
chyj4747 opened this issue Sep 27, 2021 · 6 comments
Labels
bug has-min-repro Has a minimum reproduction nw2

Comments

@chyj4747
Copy link

chyj4747 commented Sep 27, 2021

NWJS Version : 0.57.0
Operating System : win10 x64

Expected behavior

The dialog should have correct path when opened second time

Actual behavior

The path in the dialog uses _ instead of : and \
E.g. E:\Test\Abc becomes E__Test_Abc

How to reproduce

<html>
    <head></head>
    <body>
        <input type="file" nwdirectory />
    </body>
</html>

Click the input, select a path (E:\Test for example), then click the input again, this time the path in the dialog will become E__Test

First time open dialog
bug1

Second time open dialog
bug4

@sysrage
Copy link

sysrage commented Oct 3, 2021

I can confirm that I'm also seeing this behavior. I had actually seen it back in June, but it stopped showing up in the app I was working on (I assume because I started resetting nwworkingdir on each attempt). This has been present for quite some time.

@chyj4747
Copy link
Author

chyj4747 commented Oct 4, 2021

@sysrage How to reset? I tried setAttribute but it does not work. Do you mean recreating the <input>?

@sysrage
Copy link

sysrage commented Oct 4, 2021

@sysrage How to reset? I tried setAttribute but it does not work. Do you mean recreating the ?

My app is using React, so I just stored the users selection in a state variable and used that as the nwworkingdir value. Since React re-renders when state changes, I assume this completely re-created the nwdirectory input without the buggy "last" value attached.

@cark
Copy link

cark commented Oct 20, 2021

I'm also seeing this behavior on windows 10, nwjs 57.1 .

i want to save a file.

  • my input (type="file") is hidden and triggered by the onclick event of a button.
  • in the event, i set nwsaveas to a filename (maybe "myfile.txt"), and call the input click method.
  • everything works fine, the filname shows correctly in the file dialog, the file is saved in my code.
  • click on the button again, which starts the event, which sets the nwsaveas again and calls the input's click method
  • now the file dialog show a filename like this "c__projects_myapp_myfile.txt"

At that point, if i cancel and reclick the same button, reproducing the chain of events i described , the filename displayed by the file dialog is correct again.

I'm guessing it needs to see a different filename at each invocation, but just temporarily changing the attribute to a fake value is not enough.

edit: oh and I'm using react too .

@TheJaredWilcurt
Copy link
Member

One work around you can do is to do el.files.clear(). I've added this into my programmatic library, if that is easier for others to use:

@cark
Copy link

cark commented Oct 21, 2021

@TheJaredWilcurt That does the trick, thanks !

@ayushmanchhabra ayushmanchhabra added bug nw2 has-min-repro Has a minimum reproduction labels Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug has-min-repro Has a minimum reproduction nw2
Projects
None yet
Development

No branches or pull requests

5 participants