Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0208bd6

Browse files
jyash97SaraVieira
authored andcommitted
fix: new directory input validation (codesandbox#3233)
1 parent 258c81d commit 0208bd6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/EntryTitleInput/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const EntryTitleInput: FunctionComponent<Props> = ({
6363
onBlur={() => onCommit(currentValue, true)}
6464
onKeyUp={handleKeyUp}
6565
ref={select}
66+
autoComplete="new-directory"
6667
value={currentValue}
6768
id={`input-${id}`}
6869
aria-invalid={Boolean(error)}

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/validateTitle.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
export default (id, title, siblings = []) => {
22
if (title.length === 0) return 'Title cannot be empty';
3-
if (/^[09azAZ_.]+$/.test(title)) {
3+
if (title.includes(' ')) {
44
// It has whitespaces
5-
return 'Title cannot have whitespaces or special characters';
5+
return 'Title cannot have whitespaces';
6+
}
7+
if (/[!@#$%^&*(),.?":{}|<>]/g.test(title)) {
8+
return 'Title cannot have special characters';
69
}
710

811
if (title.length > 32) {

0 commit comments

Comments
 (0)