Fix for CareerSearch bar below Priorities modal

This commit is contained in:
Josh 2025-07-18 11:54:17 +00:00
parent 119576eaac
commit a8b028993a
4 changed files with 19 additions and 14 deletions

View File

@ -9,8 +9,8 @@ RUN apt-get update -y && \
# --------------------------- # ---------------------------
COPY package*.json ./ COPY package*.json ./
RUN npm ci --unsafe-perm COPY public/ /app/public/
COPY public/ /app/public/ RUN npm ci --unsafe-perm
COPY . . COPY . .
CMD ["node", "backend/server2.js"] CMD ["node", "backend/server2.js"]

View File

@ -903,6 +903,7 @@ const handleSelectForEducation = (career) => {
Explore Careers - use these tools to find your best fit Explore Careers - use these tools to find your best fit
</h2> </h2>
<CareerSearch <CareerSearch
disabled={showModal}
onCareerSelected={(careerObj) => { onCareerSelected={(careerObj) => {
console.log('[Dashboard] onCareerSelected =>', careerObj); console.log('[Dashboard] onCareerSelected =>', careerObj);
setPendingCareerForModal(careerObj); setPendingCareerForModal(careerObj);

View File

@ -71,8 +71,8 @@ const CareerPrioritiesModal = ({ userProfile, onClose }) => {
const allAnswered = questions.every(q => responses[q.id]); const allAnswered = questions.every(q => responses[q.id]);
return ( return (
<div className="fixed inset-0 bg-gray-900 bg-opacity-60 flex justify-center items-center"> <div className="fixed inset-0 bg-gray-900 bg-opacity-60 flex justify-center items-center z-50">
<div className="bg-white p-6 rounded-lg shadow-lg w-full max-w-2xl overflow-y-auto max-h-[90vh]"> <div className="bg-white p-6 rounded-lg shadow-lg w-full max-w-2xl overflow-y-auto max-h-[90vh] z-60">
<h2 className="text-xl font-bold mb-4">Tell us what's important to you</h2> <h2 className="text-xl font-bold mb-4">Tell us what's important to you</h2>
{questions.map(q => ( {questions.map(q => (
<div key={q.id} className="mb-4"> <div key={q.id} className="mb-4">

View File

@ -12,10 +12,11 @@ const normalize = (s = '') =>
.trim(); .trim();
/* ---------- component ---------- */ /* ---------- component ---------- */
const CareerSearch = ({ onCareerSelected, required }) => { const CareerSearch = ({ onCareerSelected, required, disabled: externallyDisabled = false }) => {
const [careerObjects, setCareerObjects] = useState([]); const [careerObjects, setCareerObjects] = useState([]);
const [searchInput, setSearchInput] = useState(''); const [searchInput, setSearchInput] = useState('');
const [selectedObj, setSelectedObj] = useState(null); // ✓ state const [selectedObj, setSelectedObj] = useState(null); // ✓ state
const computedDisabled = externallyDisabled || !!selectedObj;
/* fetch & de-dupe once */ /* fetch & de-dupe once */
useEffect(() => { useEffect(() => {
@ -57,6 +58,7 @@ const CareerSearch = ({ onCareerSelected, required }) => {
/* allow “Enter” to commit first suggestion */ /* allow “Enter” to commit first suggestion */
const handleKeyDown = (e) => { const handleKeyDown = (e) => {
if (computedDisabled) return;
if (e.key === 'Enter') { if (e.key === 'Enter') {
const first = careerObjects.find(o => const first = careerObjects.find(o =>
normalize(o.title).startsWith(normalize(searchInput)) normalize(o.title).startsWith(normalize(searchInput))
@ -86,19 +88,21 @@ const CareerSearch = ({ onCareerSelected, required }) => {
list="career-titles" list="career-titles"
value={searchInput} value={searchInput}
required={required} required={required}
disabled={!!selectedObj} // lock when chosen disabled={computedDisabled} // lock when chosen
onChange={(e) => setSearchInput(e.target.value)} onChange={(e) => setSearchInput(e.target.value)}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
className="w-full border rounded p-2 disabled:bg-gray-100" className={`w-full border rounded p-2
${computedDisabled ? 'bg-gray-100 cursor-not-allowed opacity-60' : ''}`}
placeholder="Start typing a career..." placeholder="Start typing a career..."
/> />
{selectedObj && ( {!computedDisabled && (
<Check <datalist id="career-titles">
className="absolute right-3 top-1/2 -translate-y-1/2 text-green-600" {careerObjects.map((o) => (
size={20} <option key={o.soc_code} value={o.title} />
/> ))}
)} </datalist>
)}
</div> </div>
{!selectedObj && ( {!selectedObj && (
@ -110,7 +114,7 @@ const CareerSearch = ({ onCareerSelected, required }) => {
)} )}
{/* change / clear link */} {/* change / clear link */}
{selectedObj && ( {selectedObj && !externallyDisabled && (
<button <button
type="button" type="button"
onClick={reset} onClick={reset}