Skip to content

fix: respect file extension setting and validate file name in save as dialog - #3468

Merged
AlexAndBear merged 4 commits into
mainfrom
fix/save-as-file-name-input
Sep 29, 2026
Merged

AlexAndBear merged 4 commits into
mainfrom
fix/save-as-file-name-input

Conversation

@AlexAndBear

Copy link
Copy Markdown
Member

Description

The file name input of the save as dialog now hides the file extension when "Show file extensions" is turned off and validates the name with the same validator as the new file/folder dialogs. Saving is disabled for empty or invalid names.

Related Issue

  • Fixes -

How Has This Been Tested?

  • test environment: local OpenCloud 8.0.0 rolling, Chrome
  • test case 1: file extensions shown / hidden → input shows New file.md / New file
  • test case 2: invalid (foo/bar.md) and empty names disable saving
  • test case 3: unit tests in EmbedActions.spec.ts

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@tammi-23 tammi-23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I found an issue were the file Extension gets removed:

  1. Disable Show file extensions.
  2. Open file.txt .
  3. Verify that the filename input correctly displays file.
  4. Open the save as and enable Show file extensions.
  5. Observe that the filename input still displays file instead of file.txt.
  6. Click Save.
  7. The file is saved as file; the .txt extension is lost.

Maybe also an issue:
If you save .-Files like .env / .gitignore they are named (1).env if the file already exist.
In my opinion it should be .env(1)

@AlexAndBear

Copy link
Copy Markdown
Member Author

@tammi-23 thanks for the review, both issues are fixed in 6f3c67c.

Lost extension after toggling "Show file extensions"
The extension handling was only evaluated once when the dialog opened. The input now follows the setting: turning it on adds the hidden extension back (file → file.txt), turning it off strips it again, and the saved name always includes the extension. While testing this I also found that .env showed up as an empty input with extensions hidden. Dot files now keep their full name, same as in the file list.

(1).env for dot files
Agreed that this was wrong. It wasn't specific to save as, copy/paste with "Keep both" had the same problem, since both use resolveFileNameDuplicate. The actual name was (1).env with a leading space. Dot files now get the suffix at the end: .env (1), .env (2), … (with a space, consistent with file (1).txt). .config.json still becomes .config (1).json.

Additionally, save as now takes the extension from the chosen name instead of the original file, so saving file.txt as .env (or notes.md) no longer produces (1).txt on a name conflict.

Tested in the browser (toggling the setting inside the save as dialog, copy/paste and save as of .env) and with unit tests.

@tammi-23 tammi-23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-reviewed the current head after the requested changes. The file extension is now preserved when toggling the setting, dot-file conflicts are resolved as .env (1), and duplicate naming uses the extension from the chosen name. The added unit tests cover the reported regressions and the full CI is green. I found no further blocking issues.

@AlexAndBear
AlexAndBear merged commit 60a5d29 into main Sep 29, 2026
31 checks passed
@AlexAndBear
AlexAndBear deleted the fix/save-as-file-name-input branch September 29, 2026 12:49
@openclouders openclouders mentioned this pull request Sep 29, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants