Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/components/onboarding/OnboardingFlow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ const OnboardingFlow = ({
() => (initialData?.profileImage && typeof initialData.profileImage === 'string' ? initialData.profileImage : '')
);
const [profileImageUploading, setProfileImageUploading] = useState(false);
const profileImageInputRef = useRef(null);
const uploadObjectUrlRef = useRef(null);
const previousFormDataRef = useRef(null);
const autosaveTimeoutRef = useRef(null);
Expand Down Expand Up @@ -512,14 +513,21 @@ const OnboardingFlow = ({
setIsDraggingImage(false);
};

const handleRemoveProfileImage = () => {
const handleRemoveProfileImage = (event) => {
event.preventDefault();
event.stopPropagation();

if (uploadObjectUrlRef.current) {
URL.revokeObjectURL(uploadObjectUrlRef.current);
uploadObjectUrlRef.current = null;
}
setProfileImagePreview('');
setFormData((previous) => ({ ...previous, profileImage: '', profileImageFile: null }));
clearProfileImageError();

if (!profileImageUploading) {
profileImageInputRef.current?.click();
}
};


Expand Down Expand Up @@ -1259,7 +1267,7 @@ const OnboardingFlow = ({
type="button"
onClick={handleRemoveProfileImage}
disabled={profileImageUploading}
className={`mt-3 inline-flex items-center rounded-md border border-gray-300 px-3 py-1 text-xs font-medium transition ${
className={`relative z-10 mt-3 inline-flex items-center rounded-md border border-gray-300 px-3 py-1 text-xs font-medium transition ${
profileImageUploading
? 'cursor-not-allowed text-gray-400'
: 'text-gray-600 hover:bg-gray-100'
Expand All @@ -1278,6 +1286,7 @@ const OnboardingFlow = ({
</>
)}
<input
ref={profileImageInputRef}
id="profileImageInput"
type="file"
accept="image/*"
Expand Down
Loading