修正完了
作付け計画画面のスクロールリセット防止: 1. fetchData に background パラメータ追加: - background = false の場合のみローディング表示 - background = true の場合はバックグラウンド更新(スピナーなし) 2. 保存ハンドラで fetchData(true) を呼び出し: - handleCropChange, handleVarietyChange, handleNotesChange の3箇所 これにより、作物・品种保存時に画面がチラついたりスクロールがリセットされたりしなくな
This commit is contained in:
@@ -17,8 +17,8 @@ export default function AllocationPage() {
|
||||
fetchData();
|
||||
}, [year]);
|
||||
|
||||
const fetchData = async () => {
|
||||
setLoading(true);
|
||||
const fetchData = async (background = false) => {
|
||||
if (!background) setLoading(true);
|
||||
try {
|
||||
const [fieldsRes, cropsRes, plansRes] = await Promise.all([
|
||||
api.get('/fields/'),
|
||||
@@ -31,7 +31,7 @@ export default function AllocationPage() {
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch data:', error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
if (!background) setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@ export default function AllocationPage() {
|
||||
notes: '',
|
||||
});
|
||||
}
|
||||
await fetchData();
|
||||
await fetchData(true);
|
||||
} catch (error) {
|
||||
console.error('Failed to save crop:', error);
|
||||
} finally {
|
||||
@@ -87,7 +87,7 @@ export default function AllocationPage() {
|
||||
variety,
|
||||
notes: existingPlan.notes,
|
||||
});
|
||||
await fetchData();
|
||||
await fetchData(true);
|
||||
} catch (error) {
|
||||
console.error('Failed to save variety:', error);
|
||||
} finally {
|
||||
@@ -108,7 +108,7 @@ export default function AllocationPage() {
|
||||
await api.patch(`/plans/${existingPlan.id}/`, {
|
||||
notes,
|
||||
});
|
||||
await fetchData();
|
||||
await fetchData(true);
|
||||
} catch (error) {
|
||||
console.error('Failed to save notes:', error);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user