fix(reviews): reset drawer state когда reviewer переключает draft
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useMemo, useState } from 'react'
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
import { createFileRoute, Link } from '@tanstack/react-router'
|
import { createFileRoute, Link } from '@tanstack/react-router'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import {
|
import {
|
||||||
@@ -631,6 +631,25 @@ function ReviewDrawer({ draftId, onClose }: DrawerProps) {
|
|||||||
* feedback теряется. */
|
* feedback теряется. */
|
||||||
const [decisionFlash, setDecisionFlash] = useState<'approve' | 'reject' | null>(null)
|
const [decisionFlash, setDecisionFlash] = useState<'approve' | 'reject' | null>(null)
|
||||||
|
|
||||||
|
// Reset state когда reviewer переключается на другой draft без закрытия
|
||||||
|
// drawer'а (click row → open new draft в already-open drawer). Раньше
|
||||||
|
// {comment, rejectError} оставались от previous draft, и mutation .error
|
||||||
|
// объекты от approveMut/rejectMut/withdrawMut held conflict banners
|
||||||
|
// ('реверсное состояние draft', '409', etc.) из predыдущей попытки —
|
||||||
|
// показывались на форме нового draft (observed bug).
|
||||||
|
useEffect(() => {
|
||||||
|
setComment('')
|
||||||
|
setRejectError(null)
|
||||||
|
setDecisionFlash(null)
|
||||||
|
approveMut.reset()
|
||||||
|
rejectMut.reset()
|
||||||
|
withdrawMut.reset()
|
||||||
|
// approveMut/rejectMut/withdrawMut references stable между renders
|
||||||
|
// (TanStack mutation hook), но lint требует exhaustive deps. .reset
|
||||||
|
// — stable function, безопасно включить.
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [draftId])
|
||||||
|
|
||||||
// Identity gates — определяют что показать в footer'е drawer'а.
|
// Identity gates — определяют что показать в footer'е drawer'а.
|
||||||
//
|
//
|
||||||
// 1. `isPending` = false: terminal draft (APPROVED/REJECTED/WITHDRAWN).
|
// 1. `isPending` = false: terminal draft (APPROVED/REJECTED/WITHDRAWN).
|
||||||
|
|||||||
Reference in New Issue
Block a user