diff --git a/android/app/build.gradle b/android/app/build.gradle index 873ec71..c128b69 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.tasktrees.app" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 7 - versionName "1.2.2" + versionCode 8 + versionName "1.2.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/package-lock.json b/package-lock.json index 8dda8fb..3d8abd3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tasktree-s", - "version": "1.2.2", + "version": "1.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tasktree-s", - "version": "1.2.2", + "version": "1.2.3", "dependencies": { "@capacitor-firebase/authentication": "^5.4.1", "@capacitor/android": "^5.7.4", diff --git a/package.json b/package.json index 082cc02..9f75a7c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tasktree-s", "private": true, - "version": "1.2.2", + "version": "1.2.3", "type": "module", "scripts": { "dev": "vite", diff --git a/src/components/SortableTree/SortableTree.tsx b/src/components/SortableTree/SortableTree.tsx index 6b88799..0f0b5b5 100644 --- a/src/components/SortableTree/SortableTree.tsx +++ b/src/components/SortableTree/SortableTree.tsx @@ -372,9 +372,11 @@ export function SortableTree({ collapsible, indicator = false, indentationWidth setItems(newItems); } } else { - // 新規タスクの場合、新規タスクを削除 + // 新規タスクの場合、新規タスクを先頭に移動し、IDを最大ID+1に更新 if (active.id === activeNewTaskId || active.id === activeQuickMemoId) { - setItems(items.filter((item) => item.id !== active.id)); + const newId = (findMaxId(items) + 1).toString(); + const updatedItems = items.map((item) => (item.id === active.id ? { ...item, id: newId, value: '' } : item)); + setItems([updatedItems.find((item) => item.id === newId)!, ...items.filter((item) => item.id !== active.id)]); const newActiveId = (parseInt(active.id.toString()) - 1).toString(); if (active.id === activeNewTaskId) { setActiveNewTaskId(newActiveId); @@ -387,9 +389,11 @@ export function SortableTree({ collapsible, indicator = false, indentationWidth function handleDragCancel() { resetState(); - // 新規タスクの場合、新規タスクを削除 + // 新規タスクの場合、新規タスクを先頭に移動し、IDを最大ID+1に更新 if (activeId === activeNewTaskId || activeId === activeQuickMemoId) { - setItems(items.filter((item) => item.id !== activeId)); + const newId = (findMaxId(items) + 1).toString(); + const updatedItems = items.map((item) => (item.id === activeId ? { ...item, id: newId, value: '' } : item)); + setItems([updatedItems.find((item) => item.id === newId)!, ...items.filter((item) => item.id !== activeId)]); const newActiveId = (parseInt(activeId.toString()) - 1).toString(); if (activeId === activeNewTaskId) { setActiveNewTaskId(newActiveId);