kaneo (minimalist kanban) fork to experiment adding a tangled integration github.com/usekaneo/kaneo
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #1157 from tinsever/fix/change-project-icon

fix: persist project icon from general settings

authored by

Andrej and committed by
GitHub
719c2c65 a48b204e

+26 -1
+26 -1
apps/web/src/routes/_layout/_authenticated/dashboard/settings/projects/$projectId/general.tsx
··· 230 230 ], 231 231 ); 232 232 233 + const saveProjectRef = useRef(saveProject); 234 + const projectFormRef = useRef(projectForm); 235 + saveProjectRef.current = saveProject; 236 + projectFormRef.current = projectForm; 237 + 233 238 const debouncedSave = useCallback(() => { 234 239 if (debounceTimeoutRef.current) { 235 240 clearTimeout(debounceTimeoutRef.current); ··· 246 251 }, [projectForm, saveProject]); 247 252 248 253 useEffect(() => { 254 + // Do not gate on formState.isDirty here: after setValue (e.g. icon pick), the 255 + // watch callback can run before RHF updates isDirty, so the debounced save never runs. 249 256 const subscription = projectForm.watch(() => { 250 - if (!projectForm.formState.isDirty) return; 251 257 debouncedSave(); 252 258 }); 253 259 ··· 258 264 return () => { 259 265 if (debounceTimeoutRef.current) { 260 266 clearTimeout(debounceTimeoutRef.current); 267 + debounceTimeoutRef.current = null; 261 268 } 269 + // Flush pending edits if the user navigates away before the debounce fires. 270 + void (async () => { 271 + const latest = projectFormRef.current.getValues() as ProjectFormValues; 272 + const normalized = normalizeProjectValues(latest); 273 + const last = lastSavedRef.current; 274 + const hasPendingChanges = 275 + !last || 276 + last.name !== normalized.name || 277 + last.slug !== normalized.slug || 278 + last.description !== normalized.description || 279 + last.icon !== normalized.icon; 280 + if (!hasPendingChanges) return; 281 + 282 + const isValid = await projectFormRef.current.trigger(); 283 + if (isValid) { 284 + await saveProjectRef.current(latest); 285 + } 286 + })(); 262 287 }; 263 288 }, []); 264 289