Skip to content

feat: use Downloads folder as default path for file dialogs - #49868

Merged
jkleinsc merged 2 commits into
mainfrom
downloads-folder
Mar 20, 2026
Merged

jkleinsc merged 2 commits into
mainfrom
downloads-folder

Conversation

@codebytere

@codebytere codebytere commented Feb 19, 2026 •

Copy link
Copy Markdown
Member

Description of Change

Closes #49237.
Supersedes #49538.

Fixes file dialogs opening in the current working directory when defaultPath is not provided. Dialogs now default to the user's Downloads folder (or Home directory if Downloads doesn't exist).

Checklist

Release Notes

Notes: File downloads will open by default in the user's Downloads folder (or Home directory if Downloads doesn't exist).

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. labels Feb 19, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Feb 19, 2026
@jkleinsc jkleinsc added semver/minor backwards-compatible functionality and removed semver/patch backwards-compatible bug fixes labels Feb 19, 2026
Comment thread shell/common/electron_paths.h Resolved
Comment thread shell/common/electron_paths.cc Resolved
Comment thread shell/browser/ui/file_dialog_win.cc Resolved
@codebytere
codebytere requested a review from ckerr February 20, 2026 08:57
@codebytere
codebytere force-pushed the downloads-folder branch 3 times, most recently from 8fdaeac to 47e8894 Compare February 21, 2026 08:42
@codebytere
codebytere requested a review from jkleinsc February 24, 2026 16:05

@jkleinsc jkleinsc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document this as a breaking change since it changes current behavior. Its possible some applications are currently depending on this defaulting to the current working directory.

@codebytere
codebytere requested a review from jkleinsc February 25, 2026 13:13
@codebytere
codebytere requested a review from a team as a code owner February 25, 2026 13:13

@jkleinsc jkleinsc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Feb 26, 2026
@codebytere codebytere changed the title fix: use Downloads folder as default path for file dialogs feat: use Downloads folder as default path for file dialogs Mar 4, 2026
@codebytere
codebytere requested a review from jkleinsc March 4, 2026 11:28
Comment thread docs/api/dialog.md
* `options` Object
* `title` string (optional)
* `defaultPath` string (optional)
* `defaultPath` string (optional) - Absolute directory path, absolute file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user has previously selected a different folder using a file dialog, that will still override the defaultPath value, correct? If so we should mention that behavior.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the updated example for preserving old behavior helps clarify this for me.

A less confusing property name might be initialPath, but I'm OK saving that for a follow-up, unless we want to combine all the breaking changes into one release.

Comment thread docs/breaking-changes.md Outdated
* `dialog.showSaveDialog`
* `dialog.showSaveDialogSync`

Previously, these methods used the last-opened directory or an OS-determined default. To preserve the old behavior, explicitly pass `defaultPath` when calling these methods.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a little confusing as-worded. IIUC the last-opened directory behavior isn't changing. It's just the OS-determined default that is now changing to Downloads, with a Home dir fallback.

How easy will it be for app developers to replicate the "OS-determined default" in order to pass it to defaultPath. If they just want the current working directory that's pretty easy, but is that the current behavior across OSes?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itsananderson tried to improve it!

@github-actions github-actions Bot added the target/42-x-y PR should also be added to the "42-x-y" branch. label Mar 13, 2026

@erickzhao erickzhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@samuelmaddock samuelmaddock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

Comment thread docs/breaking-changes.md
if (!result.canceled && result.filePaths.length > 0) {
lastUsedPath = path.dirname(result.filePaths[0])
}
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

@itsananderson itsananderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

Comment thread docs/api/dialog.md
* `options` Object
* `title` string (optional)
* `defaultPath` string (optional)
* `defaultPath` string (optional) - Absolute directory path, absolute file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the updated example for preserving old behavior helps clarify this for me.

A less confusing property name might be initialPath, but I'm OK saving that for a follow-up, unless we want to combine all the breaking changes into one release.

@jkleinsc jkleinsc added no-backport and removed target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Mar 20, 2026
@jkleinsc
jkleinsc merged commit 7f21d31 into main Mar 20, 2026
209 of 212 checks passed
@jkleinsc
jkleinsc deleted the downloads-folder branch March 20, 2026 21:28
@release-clerk

release-clerk Bot commented Mar 20, 2026

Copy link
Copy Markdown

Release Notes Persisted

File downloads will open by default in the user's Downloads folder (or Home directory if Downloads doesn't exist).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When first calling dialog.showSaveDialog, default to downloads/documents

6 participants