fix: config profile form focus loss and path validation messages
- Fix React key stability in env vars, files, and mount file inputs to prevent focus loss on every keystroke - Improve validation error messages to explain Files vs Mounts - Add helper text in UI clarifying relative vs absolute paths Fixes focus loss bug and improves UX for path validation errors.
This commit is contained in:
@@ -78,8 +78,13 @@ class MountItem(BaseModel):
|
||||
@classmethod
|
||||
def validate_files(cls, v: dict) -> dict:
|
||||
for path in v.keys():
|
||||
if ".." in path or path.startswith("/") or not path:
|
||||
if ".." in path or not path:
|
||||
raise ValueError(f"Invalid file path: {path}")
|
||||
if path.startswith("/"):
|
||||
raise ValueError(
|
||||
f"Mount file paths must be relative (got: {path}). "
|
||||
f"The mount target defines the absolute container path."
|
||||
)
|
||||
return v
|
||||
|
||||
|
||||
@@ -103,8 +108,13 @@ class ConfigProfileCreate(BaseModel):
|
||||
@classmethod
|
||||
def validate_files(cls, v: dict) -> dict:
|
||||
for path in v.keys():
|
||||
if ".." in path or path.startswith("/") or not path:
|
||||
if ".." in path or not path:
|
||||
raise ValueError(f"Invalid file path: {path}")
|
||||
if path.startswith("/"):
|
||||
raise ValueError(
|
||||
f"File paths must be relative (got: {path}). "
|
||||
f"Use Mounts for absolute container paths."
|
||||
)
|
||||
return v
|
||||
|
||||
@field_validator("env_vars")
|
||||
|
||||
Reference in New Issue
Block a user