Skip to content

Add empty name validation to files#1427

Open
jamiebenstead wants to merge 3 commits intomainfrom
Add-empty-name-validation-to-files
Open

Add empty name validation to files#1427
jamiebenstead wants to merge 3 commits intomainfrom
Add-empty-name-validation-to-files

Conversation

@jamiebenstead
Copy link
Copy Markdown
Contributor

Add validation to prevent a file being created/updated without a name such as .txt for example.

Copilot AI review requested due to automatic review settings April 10, 2026 13:40
@jamiebenstead jamiebenstead temporarily deployed to previews/1427/merge April 10, 2026 13:41 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds validation to prevent creating/renaming files with an empty base name (e.g., .py), wiring in a new localized error message and covering the behavior with modal tests.

Changes:

  • Updated filename validation to reject dot-prefixed “no name” inputs and dispatch a dedicated emptyFileName error.
  • Added unit tests for New File and Rename File modals to assert the new error behavior.
  • Added an English translation string for the new validation error.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/utils/componentNameValidation.js Introduces base-name extraction and dispatches a new empty-name error when appropriate.
src/components/Modals/RenameFileModal.test.js Adds a test ensuring renaming to .py triggers the empty-name error.
src/components/Modals/NewFileModal.test.js Adds a test ensuring creating .py triggers the empty-name error.
public/translations/en.json Adds the filePanel.errors.emptyFileName translation entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 64 to +68
}),
),
);
} else if (baseName.length === 0) {
dispatch(setNameError(t("filePanel.errors.emptyFileName")));
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

The emptyFileName branch runs after the unsupported-extension branch. For truly blank inputs like "" or ".", extension is "" so this function will currently dispatch unsupportedExtension rather than the new emptyFileName message. Consider checking fileName.trim().length === 0 / baseName.length === 0 before extension validation (or explicitly handling extension === "") so empty inputs consistently show the empty-name error.

Copilot uses AI. Check for mistakes.
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.

2 participants