修正完了

作付け計画画面のスクロールリセット防止:
1. fetchData に background パラメータ追加:
   - background = false の場合のみローディング表示
   - background = true の場合はバックグラウンド更新(スピナーなし)
2. 保存ハンドラで fetchData(true) を呼び出し:
   - handleCropChange, handleVarietyChange, handleNotesChange の3箇所
これにより、作物・品种保存時に画面がチラついたりスクロールがリセットされたりしなくな
This commit is contained in:
Akira
2026-02-15 14:57:26 +09:00
parent 2cfd528173
commit 15a94867fa

View File

@@ -17,8 +17,8 @@ export default function AllocationPage() {
fetchData(); fetchData();
}, [year]); }, [year]);
const fetchData = async () => { const fetchData = async (background = false) => {
setLoading(true); if (!background) setLoading(true);
try { try {
const [fieldsRes, cropsRes, plansRes] = await Promise.all([ const [fieldsRes, cropsRes, plansRes] = await Promise.all([
api.get('/fields/'), api.get('/fields/'),
@@ -31,7 +31,7 @@ export default function AllocationPage() {
} catch (error) { } catch (error) {
console.error('Failed to fetch data:', error); console.error('Failed to fetch data:', error);
} finally { } finally {
setLoading(false); if (!background) setLoading(false);
} }
}; };
@@ -64,7 +64,7 @@ export default function AllocationPage() {
notes: '', notes: '',
}); });
} }
await fetchData(); await fetchData(true);
} catch (error) { } catch (error) {
console.error('Failed to save crop:', error); console.error('Failed to save crop:', error);
} finally { } finally {
@@ -87,7 +87,7 @@ export default function AllocationPage() {
variety, variety,
notes: existingPlan.notes, notes: existingPlan.notes,
}); });
await fetchData(); await fetchData(true);
} catch (error) { } catch (error) {
console.error('Failed to save variety:', error); console.error('Failed to save variety:', error);
} finally { } finally {
@@ -108,7 +108,7 @@ export default function AllocationPage() {
await api.patch(`/plans/${existingPlan.id}/`, { await api.patch(`/plans/${existingPlan.id}/`, {
notes, notes,
}); });
await fetchData(); await fetchData(true);
} catch (error) { } catch (error) {
console.error('Failed to save notes:', error); console.error('Failed to save notes:', error);
} finally { } finally {