-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: prevent empty mode names from being saved (fixes #5766) #5767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
73c2f82
48b7d76
24f8d56
3027559
16bb8e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -755,17 +755,25 @@ const ModesView = ({ onDone }: ModesViewProps) => { | |
| } | ||
| }} | ||
| onChange={(e) => { | ||
| setLocalModeName(e.target.value) | ||
| const newName = e.target.value | ||
| // Allow users to type freely, including emptying the field | ||
| setLocalModeName(newName) | ||
| }} | ||
| onBlur={() => { | ||
| const customMode = findModeBySlug(visualMode, customModes) | ||
| if (customMode && localModeName.trim()) { | ||
| if (customMode) { | ||
| const trimmedName = localModeName.trim() | ||
| // Only update if the name is not empty | ||
| updateCustomMode(visualMode, { | ||
| ...customMode, | ||
| name: localModeName, | ||
| source: customMode.source || "global", | ||
| }) | ||
| if (trimmedName) { | ||
| updateCustomMode(visualMode, { | ||
| ...customMode, | ||
| name: trimmedName, | ||
| source: customMode.source || "global", | ||
| }) | ||
| } else { | ||
| // Revert to the original name if empty | ||
| setLocalModeName(customMode.name) | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mentioned adding an The onBlur handler would restore the original value if the user leaves the field empty, providing better UX while still preventing invalid saves. |
||
| // Clear the editing state | ||
| setCurrentEditingModeSlug(null) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backend validation implementation looks solid! Using
modeConfigSchema.safeParse()with proper error handling and user-friendly messages is exactly what we need. At least I got something right.