diff --git a/site/src/pages/RoadmapPage/AddYearPopup.tsx b/site/src/pages/RoadmapPage/AddYearPopup.tsx index 147349b1..747378cb 100644 --- a/site/src/pages/RoadmapPage/AddYearPopup.tsx +++ b/site/src/pages/RoadmapPage/AddYearPopup.tsx @@ -6,16 +6,22 @@ import { addYear } from '../../store/slices/roadmapSlice'; import { useAppDispatch } from '../../store/hooks'; interface AddYearPopupProps { + placeholderName: string; placeholderYear: number; } -const AddYearPopup: FC = ({ placeholderYear }) => { +const AddYearPopup: FC = ({ placeholderName, placeholderYear }) => { const dispatch = useAppDispatch(); + const [name, setName] = useState(placeholderName); const [year, setYear] = useState(placeholderYear); + const [validated, setValidated] = useState(false); const [show, setShow] = useState(false); const target = useRef(null); - useEffect(() => { setYear(placeholderYear) }, [placeholderYear]); + useEffect(() => { + setYear(placeholderYear); + setName(placeholderName); + }, [placeholderYear, placeholderName]); const handleClick = (event: React.MouseEvent) => { setShow(!show); @@ -30,12 +36,35 @@ const AddYearPopup: FC = ({ placeholderYear }) => { -
+ + + + Name + + { + setName(e.target.value); + }} + onKeyDown={(e: React.KeyboardEvent) => { + // prevent submitting form (reloads the page) + if (e.key === 'Enter') { + e.preventDefault(); + } + }} + maxLength={35} + placeholder={placeholderName} + > + Start Year = ({ placeholderYear }) => {