Skip to content

docs: mark "Show hidden files" file dialog setting as deprecated on Linux#46926

Merged
jkleinsc merged 3 commits into
electron:mainfrom
zonescape:hidden-files-gnome
Feb 25, 2026
Merged

docs: mark "Show hidden files" file dialog setting as deprecated on Linux#46926
jkleinsc merged 3 commits into
electron:mainfrom
zonescape:hidden-files-gnome

Conversation

@zonescape

@zonescape zonescape commented May 5, 2025

Copy link
Copy Markdown
Contributor

Description of Change

Closes #46817

GTK file chooser doesn't need special setup regarding hidden files. Current code just overwrites system wide user preferences.

As far as I understand showHiddenFiles property is supposed to be application wide. If this is correct then this property can't be implemented for GTK dialogs because they read/write system wide "Show hidden files" setting.

This is a draft PR because I can't check my code. My computer hangs on gclient sync --with_branch_heads --with_tags command from these instructions. Typing in terminal doesn't work, mouse is not moving, I can't even use tty3 because of login timeout. Switched off the computer. I hope somebody can test my solution.

@ckerr @codebytere @deepak1556

Checklist

Release Notes

Notes: Marked "Show hidden files" setting as deprecated on Linux/GNOME

@zonescape zonescape requested a review from a team as a code owner May 5, 2025 10:55
@welcome

welcome Bot commented May 5, 2025

Copy link
Copy Markdown

💖 Thanks for opening this pull request! 💖

Semantic PR titles

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Commit signing

This repo enforces commit signatures for all incoming PRs.
To sign your commits, see GitHub's documentation on Telling Git about your signing key.

PR tips

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label May 5, 2025
@zonescape zonescape marked this pull request as draft May 5, 2025 10:56
@deepak1556

Copy link
Copy Markdown
Member

Thanks for starting this change, additional context in #34706 (comment). As discussed before, to make this a semver-patch change we should use the current system value via gtk_file_chooser_get_show_hidden when showHiddenFiles is not set

@zonescape

Copy link
Copy Markdown
Contributor Author

@deepak1556 I read that comment before. gtk_file_chooser_get_show_hidden doesn't return current system value. It is a getter for show-hidden property of a dialog. It just returns whatever value you put into gtk_file_chooser_set_show_hidden() starting with false.

GtkFileChooser* chooser = gtk_file_chooser_dialog_new(...);

gtk_file_chooser_get_show_hidden(chooser);        // always returns false
gtk_file_chooser_set_show_hidden(chooser, true);
gtk_file_chooser_get_show_hidden(chooser);        // true
gtk_file_chooser_set_show_hidden(chooser, false);
gtk_file_chooser_get_show_hidden(chooser);        // false

It must be emphasized that the current code does nothing but breaks user experience. I don't see any useful effects from it. Therefore its removal should be considered as a semver patch.

Moreover, as I said before, I can't test my code because my computer can't handle gclient sync .... I can write drafts only.

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label May 12, 2025
@zonescape zonescape marked this pull request as ready for review November 10, 2025 08:16
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Nov 10, 2025
@zonescape

Copy link
Copy Markdown
Contributor Author

I was finally able to compile Electron. I can confirm that this patch works.

@zonescape

Copy link
Copy Markdown
Contributor Author

I made a rebase to resolve conflicts

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Nov 17, 2025
@ckerr ckerr added platform/linux semver/patch backwards-compatible bug fixes no-backport labels Nov 24, 2025

@ckerr ckerr 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.

@zonescape's right -- #46817 is a valid bug -- but I don't think we should take this patch as-is.

This patch does honor the user's default settings, but it stops honoring any showHiddenFiles value passed into the options.properties: string[] in dialog.showOpenDialogSync() et al. on Linux.

I think the root bug is that Electron's Linux code unconditionally calls SetHiddenShown() whether or not showHiddenFiles was present in options.properties. This causes a system preference of "show hidden files" to get clobbered if options.properties is empty.

IMO we should not change the patch file. Instead, @zonescape WDYT about making this change instead:

diff --git a/shell/browser/ui/file_dialog_linux.cc b/shell/browser/ui/file_dialog_linux.cc
index 56251d9717..1ddd7c34dd 100644
--- a/shell/browser/ui/file_dialog_linux.cc
+++ b/shell/browser/ui/file_dialog_linux.cc
@@ -197,7 +197,8 @@ class FileChooserDialog : public ui::SelectFileDialog::Listener {
     int hidden_flag = type_ == DialogType::SAVE
                           ? static_cast<int>(SAVE_DIALOG_SHOW_HIDDEN_FILES)
                           : static_cast<int>(OPEN_DIALOG_SHOW_HIDDEN_FILES);
-    dialog_->SetHiddenShown(settings.properties & hidden_flag);
+    if (settings.properties & hidden_flag)
+      dialog_->SetHiddenShown(true);
   }
 
   DialogType type_;

@ckerr ckerr assigned ckerr and unassigned ckerr Nov 24, 2025
@ckerr ckerr added target/38-x-y PR should also be added to the "38-x-y" branch. target/39-x-y PR should also be added to the "39-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. and removed no-backport labels Nov 24, 2025
@zonescape

Copy link
Copy Markdown
Contributor Author

@ckerr your code doesn't change anything because gtk_file_chooser_set_show_hidden() is always called. However, we can add one more method in ui/gtk/select_file_dialog_linux_gtk.cc and call it, instead of direct call of gtk_file_chooser_set_show_hidden():

void SelectFileDialogLinuxGtk::GtkFileChooserSetShowHidden(GtkFileChooser* chooser) {
  if (!show_hidden()) {
    // partial fix for gtk_file_chooser_set_show_hidden()
    // overwriting the system value of the is-hidden property
    return;
  }
  gtk_file_chooser_set_show_hidden(chooser, show_hidden()); // overwriting
}

But I don't understand why users who run Electron apps with showHiddenFiles property set must suffer from the bug? What is special about them?

As far as I understand, Electron's "show hidden files" feature can not be implemented for GTK3 dialogs. It literally can not be implemented. Whatever we do will break the user experience. Therefore I don't understand what we are trying to achieve? To break user expierience in half? By a quarter? Why?

Electron apps are infamous for their non native look and behaviour. This issue is a perfect example of non native behaviour. I think this should be avoided as much as possible.

As for app developers, I propose to add corresponding docs (see code).

@ckerr

ckerr commented Nov 25, 2025

Copy link
Copy Markdown
Member

As far as I understand, Electron's "show hidden files" feature can not be implemented for GTK3 dialogs. It literally can not be implemented. Whatever we do will break the user experience. Therefore I don't understand what we are trying to achieve? To break user expierience in half? By a quarter? Why?

This feature was added before my time, so I'd have to use the commit history the same as you to know why this feature exists. It's because it was requested in #3262 and implemented in #6431. From the screenshot included in 3262, it looks like one use case at the time was for using a file chooser to select ssh keys that could be located in hidden directories like ~/.ssh.

So nobody in this PR was there at the time, but feel free to throw abuse at me anyway. If you'd like to continue in this vein, I can step away from this PR and maybe another maintainer will work with you.

As far as I understand, Electron's "show hidden files" feature can not be implemented for GTK3 dialogs. It literally can not be implemented. Whatever we do will break the user experience.

If by this you mean it's unavoidable that we let apps do this without clobbering the user settings -- I think that's technically not true. We could work around this by caching the user's preference before opening the chooser, and then restoring it as part of chooser teardown.

But if by this you mean "no app on GNOME desktops should have this feature" then I think I agree. And on just a pragmatic level, this feature will be removed sooner or later because gtk_file_chooser_set_show_hidden() was removed upstream in https://gitlab.gnome.org/GNOME/gtk/-/commit/516eab5c4374189600a19499d8f7db659d1157b2 as part of https://gitlab.gnome.org/GNOME/gtk/-/issues/2455 with the description "remove the show-hidden property; this is a user toggle, not something to set programmatically." For that reason, I'd be OK with making a breaking change to remove support for this on GTK.

@ckerr ckerr 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.

Removing support for this feature on GNOME / *nix is a breaking change, so we need to deprecate it now and then remove it after the deprecation period.

  1. In docs use the annotations _macOS_, _Windows_, _Linux_ to say what platforms a feature works on. We use the annotation _Deprecated_ to mark deprecated API. We don't seem to have something for API deprecated only on one platform, so my inline suggestions of _macOS_ _Windows_ _Deprecated + the comment "Deprecated on Linux" is probably close enough.

  2. Needs a comment in https://github.com/electron/electron/blob/main/docs/breaking-changes.md#planned-breaking-api-changes-400 along the lines of

### Deprecated: `showHiddenFiles` in Dialogs on Linux

This property will still be honored on macOS and Windows, but support on Linux
will be removed in Electron 41. GTK intends for this to be a user choice rather
than an app choice and has removed the API to do this programmatically.
  1. Don't change feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch in this PR. That will have to wait for after the deprecation period.

Comment thread docs/api/dialog.md Outdated
Comment thread docs/api/dialog.md Outdated
Comment thread docs/api/dialog.md Outdated
Comment thread docs/api/dialog.md Outdated
@ckerr ckerr removed semver/patch backwards-compatible bug fixes target/38-x-y PR should also be added to the "38-x-y" branch. labels Nov 25, 2025
@zonescape

Copy link
Copy Markdown
Contributor Author

@ckerr done

@zonescape zonescape requested a review from ckerr December 6, 2025 19:25
@github-actions github-actions Bot added the target/41-x-y PR should also be added to the "41-x-y" branch. label Jan 19, 2026
@ckerr ckerr removed no-backport target/39-x-y PR should also be added to the "39-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. labels Feb 19, 2026
@ckerr ckerr changed the title fix: don't overwrite "Show hidden files" setting in Linux/GNOME docs: mark "Show hidden files" file dialog setting as deprecated on Linux Feb 19, 2026
@ckerr ckerr force-pushed the hidden-files-gnome branch from f09a025 to 4a97eda Compare February 20, 2026 00:38
@ckerr

ckerr commented Feb 20, 2026

Copy link
Copy Markdown
Member

(rebased to main in electron/electron)

@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.

Given where we are in the release cycle, I believe it is too late to mark this as deprecated in 40 and removed in 41. We should mark it as deprecated for 41 and remove in a future release.

@ckerr ckerr force-pushed the hidden-files-gnome branch from 4a97eda to 7d3a4eb Compare February 24, 2026 22:10
@ckerr

ckerr commented Feb 24, 2026

Copy link
Copy Markdown
Member

@jkleinsc moved to 42 in 7d3a4eb

@jkleinsc jkleinsc merged commit b9a09ac into electron:main Feb 25, 2026
30 checks passed
@welcome

welcome Bot commented Feb 25, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk

release-clerk Bot commented Feb 25, 2026

Copy link
Copy Markdown

Release Notes Persisted

Marked "Show hidden files" setting as deprecated on Linux/GNOME

@trop

trop Bot commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "41-x-y", please check out #49948

@trop trop Bot added in-flight/41-x-y merged/41-x-y PR was merged to the "41-x-y" branch. and removed target/41-x-y PR should also be added to the "41-x-y" branch. in-flight/41-x-y labels Feb 25, 2026
kycutler pushed a commit to kycutler/electron that referenced this pull request Feb 26, 2026
…inux (electron#46926)

* fix: don't overwrite "Show hidden files" setting on Linux/GTK

* docs: deprecate showHiddenFiles property in dialogs on Linux

* docs: mark Electron 42 as the removal date for this feature

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GTK3 file chooser overwrites "Show hidden files" setting in Linux/GNOME

4 participants