Skip to content
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

feat: Show feedback when special characters are entered in branch name #229

Merged
merged 8 commits into from
Feb 16, 2023
12 changes: 11 additions & 1 deletion taxonomy-editor-frontend/src/pages/startproject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const StartProject = ({ clearNavBarLinks }) => {
const [description, setDescription] = useState("");
const [loading, setLoading] = useState(false);
const [errorMessage, setErrorMessage] = useState("");
const [showBranchNameError, setShowBranchNameError] = useState(false);
const navigate = useNavigate();

useEffect(
Expand Down Expand Up @@ -96,10 +97,19 @@ const StartProject = ({ clearNavBarLinks }) => {

<div>
<TextField
error={showBranchNameError}
helperText={showBranchNameError && "Special characters or white spaces are not allowed"}
size="small"
sx={{ width: 265, mt: 2 }}
onChange={(event) => {
setBranchName(event.target.value);
const specialChar = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\s]+/;
if(specialChar.test(event.target.value)){
setShowBranchNameError(true);
}
else{
setShowBranchNameError(false)
}
}}
value={branchName}
variant="outlined"
Expand All @@ -125,7 +135,7 @@ const StartProject = ({ clearNavBarLinks }) => {
variant="contained"
sx={{ mt: 3 }}
onClick={handleSubmit}
disabled={!branchName || !taxonomyName || loading}
disabled={!branchName || !taxonomyName || loading || showBranchNameError}
>
{loading ? (
<>
Expand Down