Skip to content

Commit 3027559

Browse files
committed
fix: allow emptying mode name field but prevent saving when invalid
- Modified onBlur handler to check if name is empty before saving - If empty, revert to original name instead of saving empty value - This provides better UX as requested in PR review
1 parent 24f8d56 commit 3027559

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

webview-ui/src/components/modes/ModesView.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -757,17 +757,23 @@ const ModesView = ({ onDone }: ModesViewProps) => {
757757
onChange={(e) => {
758758
const newName = e.target.value
759759
// Allow users to type freely, including emptying the field
760-
// The backend validation will handle empty names and show errors
761760
setLocalModeName(newName)
762761
}}
763762
onBlur={() => {
764763
const customMode = findModeBySlug(visualMode, customModes)
765764
if (customMode) {
766-
updateCustomMode(visualMode, {
767-
...customMode,
768-
name: localModeName.trim(),
769-
source: customMode.source || "global",
770-
})
765+
const trimmedName = localModeName.trim()
766+
// Only update if the name is not empty
767+
if (trimmedName) {
768+
updateCustomMode(visualMode, {
769+
...customMode,
770+
name: trimmedName,
771+
source: customMode.source || "global",
772+
})
773+
} else {
774+
// Revert to the original name if empty
775+
setLocalModeName(customMode.name)
776+
}
771777
}
772778
// Clear the editing state
773779
setCurrentEditingModeSlug(null)

0 commit comments

Comments
 (0)