diff --git a/frontend/src/components/PostEditForm.test.tsx b/frontend/src/components/PostEditForm.test.tsx
index 1fc58a9..2ff28b1 100644
--- a/frontend/src/components/PostEditForm.test.tsx
+++ b/frontend/src/components/PostEditForm.test.tsx
@@ -66,4 +66,27 @@ describe ('PostEditForm', () => {
expect (onSave).toHaveBeenCalledWith (expect.objectContaining ({ versionNo: 5 }))
expect (toastApi.toast).toHaveBeenCalledWith ({ description: '更新しました.' })
})
+
+ it ('preserves duration while the video tag is temporarily removed', () => {
+ const post = buildPost ({
+ videoMs: 180_500,
+ tags: [
+ buildTag ({ id: 1, name: '動画', category: 'general' }),
+ buildTag ({ id: 2, name: 'general-tag', category: 'general' }),
+ ],
+ })
+
+ render ()
+
+ expect (screen.getByRole ('spinbutton')).toHaveValue (180.5)
+
+ const tags = screen.getAllByRole ('textbox')[2]
+ fireEvent.change (tags, { target: { value: 'general-tag' } })
+ expect (screen.queryByRole ('spinbutton')).not.toBeInTheDocument ()
+
+ fireEvent.change (tags, {
+ target: { value: '動画 general-tag' },
+ })
+ expect (screen.getByRole ('spinbutton')).toHaveValue (180.5)
+ })
})
diff --git a/frontend/src/components/PostEditForm.tsx b/frontend/src/components/PostEditForm.tsx
index c1fdd72..744c132 100644
--- a/frontend/src/components/PostEditForm.tsx
+++ b/frontend/src/components/PostEditForm.tsx
@@ -153,11 +153,6 @@ const PostEditForm: FC = ({ post, onSave }) => {
setDuration (videoMsToDurationValue (post.videoMs))
}, [post])
- useEffect (() => {
- if (!(videoFlg))
- setDuration ('')
- }, [videoFlg])
-
return (