From 469153d7647d12fbf27ce3ce1dc855b68b522bc4 Mon Sep 17 00:00:00 2001 From: Jun Murakami <126404131+Jun-Murakami@users.noreply.github.com> Date: Tue, 14 May 2024 16:19:52 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=82=921.2.2=E3=81=8B=E3=82=891.2.3=E3=81=AB=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=81=97=E3=80=81=E6=96=B0=E8=A6=8F=E3=82=BF=E3=82=B9?= =?UTF-8?q?=E3=82=AF=E3=81=AE=E8=BF=BD=E5=8A=A0=E3=81=A8ID=E3=81=AE?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E3=82=92=E8=A1=8C=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- src/components/SortableTree/SortableTree.tsx | 12 ++++++++---- 4 files changed, 13 insertions(+), 9 deletions(-) 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);