From 4d6aa7ee0db32d20e2870c1686df2122ce4f1fb2 Mon Sep 17 00:00:00 2001 From: The Jared Wilcurt <4629794+TheJaredWilcurt@users.noreply.github.com> Date: Thu, 21 Oct 2021 09:53:58 -0400 Subject: [PATCH] Work around bug --- index.js | 7 +++++++ package-lock.json | 8 ++++---- package.json | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 1ff81b8..942c2f6 100644 --- a/index.js +++ b/index.js @@ -83,6 +83,13 @@ function openFolderExplorer (window, options, callback) { element.removeAttribute(NW_DIRECTORY_DESCRIPTION); } + // Clear out the previous value before opening the dialogu to work around + // a bug where a transformed version of the previous value is shown in the + // dialog like 'C__Users_Bob_Desktop'. See: github.com/nwjs/nw.js/issues/7786 + if (element && element.files && element.files.clear) { + element.files.clear(); + } + // Trigger a click event to cause the dialog to open element.click(); } diff --git a/package-lock.json b/package-lock.json index 1027190..b036704 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "nw-programmatic-folder-select", - "version": "1.0.4", + "version": "1.0.5", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -80,9 +80,9 @@ "dev": true }, "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, "ansi-styles": { diff --git a/package.json b/package.json index 8cc75cc..13e964c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nw-programmatic-folder-select", - "version": "1.0.4", + "version": "1.0.5", "description": "Programmatically open a native folder select dialog in NW.js", "main": "index.js", "scripts": {