Skip to content

fix(js): keep dialog.pickFile() open until the user selects - #3094

Open
sergarsilla wants to merge 1 commit into
BruceDevices:devfrom
sergarsilla:fix/js-pickfile-interpreter
Open

sergarsilla wants to merge 1 commit into
BruceDevices:devfrom
sergarsilla:fix/js-pickfile-interpreter

Conversation

@sergarsilla

Copy link
Copy Markdown
Contributor

Proposed Changes

dialog.pickFile() in the JS interpreter returns the first file immediately instead of waiting for the user to choose. native_dialogPickFile() calls loopSD(), which runs its file-list loopOptions() with interpreter = false. While the interpreter is running (interpreter_state > 0), loopOptions() breaks out of its input loop immediately when that flag is false, so loopSD() kept the default index (0) and returned the first file without any user interaction.

This threads an interpreter flag through loopSD() (defaulting to false, so every existing caller is unchanged) and forwards it to the file-list loopOptions() call. dialog.pickFile() now passes true, keeping the picker open until the user selects a file or cancels.

Types of Changes

Bugfix

Verification

Run a script that calls dialog.pickFile("/", "*"): the file browser now stays open until a file is selected (returns the path) or the user cancels (returns ""), instead of returning the first entry instantly. Matches the original report using the Key Decoding app's "Load" menu on a T-Embed CC1101.

Testing

Builds clean for lilygo-t-embed-cc1101. Manually verifiable on-device as above; no automated test added (interactive menu/UI code without existing unit-test coverage).

Linked Issues

Fixes #3084

User-Facing Change

```release-note
Fix dialog.pickFile() in the JS interpreter returning the first file instead of waiting for a selection.
```

Further Comments

Minimal, scoped change. The same early-break also affects the long-press action sub-menus inside loopSD() (rename/delete/new-folder) when invoked from the interpreter; left as-is since they're outside the reported file-picking flow and could be a follow-up.

native_dialogPickFile() calls loopSD(), which ran its file-list
loopOptions() with interpreter=false. While the JS interpreter is running
(interpreter_state > 0), loopOptions() breaks out of its input loop
immediately when that flag is false, so loopSD() kept the default index and
returned the first file without any user interaction.

Thread an `interpreter` flag through loopSD() (default false, so every
existing caller is unchanged) and forward it to the file-list loopOptions()
call. dialog.pickFile() now passes true, keeping the picker open until the
user selects a file or cancels.

Fixes BruceDevices#3084

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant