fix(ui): give feedback when the project name slugifies to empty - #31
Open
CatJuly wants to merge 1 commit into
Open
fix(ui): give feedback when the project name slugifies to empty#31CatJuly wants to merge 1 commit into
CatJuly wants to merge 1 commit into
Conversation
Creating a project does nothing when the typed name contains no ASCII word characters — for example a fully Chinese name like "知识工程". handleCreate slugifies the input through [^a-z0-9_-] before submitting, and when everything is stripped it bails out with a bare `return`, so the "+" click appears dead with no hint about what went wrong. Derive the slug live while typing. When the name is non-empty but the slug is empty, mark the input invalid (red outline, tooltip, and a small anchored hint that does not shift the topbar layout) and disable the submit button, so the constraint is visible before the click instead of being swallowed after it. Verified with `npm run typecheck` and `npm run build`; manually checked that Chinese-only input shows the invalid state with the hint, that mixed input like "My App" still creates as "my-app", and that plain ASCII names are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Clicking + to create a project silently does nothing when the typed name contains no ASCII word characters — for example a fully Chinese name like
知识工程.Repro: Workspace top bar →
+→ type知识工程→ press Enter or click+. Nothing happens: no project, no error, no visual change.Root cause
handleCreateinProjectSelector.tsxslugifies the input before submitting:The slug restriction itself is correct — the backend rejects anything outside
[a-z0-9_-](is_safe_project_id). The bug is purely that the constraint is invisible: the click is dropped with no feedback, which reads as a dead button.Fix
Derive the slug live while typing (same regex, extracted to
toProjectSlug). When the name is non-empty but the slug is empty:aria-invalid, and a tooltipValid input behaves exactly as before —
My Appstill createsmy-app, plain ASCII names are unaffected.Testing
npm run typecheck— cleannpm run build— clean; rebuiltfrontend_distbundle includedMy Appcreatesmy-app;demo-2creates unchanged; Escape still closes the formScope
Frontend only (
ProjectSelector.tsx, two i18n keys, rebuilt dist). No backend or validation-rule changes.