feat: add initial file path support and scrolling behavior in ChangeReviewDialog
- Introduced an `initialFilePath` prop to facilitate scrolling to a specific file upon loading. - Implemented a mechanism to reset the scroll flag when `initialFilePath` changes. - Enhanced the scrolling functionality to automatically scroll to the specified file once the data is loaded, improving user navigation during reviews.
This commit is contained in:
parent
1c6b7c4ef1
commit
a5da786343
1 changed files with 21 additions and 0 deletions
|
|
@ -29,6 +29,7 @@ interface ChangeReviewDialogProps {
|
|||
mode: 'agent' | 'task';
|
||||
memberName?: string;
|
||||
taskId?: string;
|
||||
initialFilePath?: string;
|
||||
}
|
||||
|
||||
function isTaskChangeSetV2(cs: { teamName: string }): cs is TaskChangeSetV2 {
|
||||
|
|
@ -42,6 +43,7 @@ export const ChangeReviewDialog = ({
|
|||
mode,
|
||||
memberName,
|
||||
taskId,
|
||||
initialFilePath,
|
||||
}: ChangeReviewDialogProps): React.ReactElement | null => {
|
||||
const {
|
||||
activeChangeSet,
|
||||
|
|
@ -92,6 +94,9 @@ export const ChangeReviewDialog = ({
|
|||
: null;
|
||||
}, [activeFilePath]);
|
||||
|
||||
// One-shot scroll-to-file ref (for initialFilePath)
|
||||
const initialScrollDoneRef = useRef(false);
|
||||
|
||||
// Continuous scroll navigation
|
||||
const { scrollToFile, isProgrammaticScroll } = useContinuousScrollNav({
|
||||
scrollContainerRef,
|
||||
|
|
@ -255,6 +260,22 @@ export const ChangeReviewDialog = ({
|
|||
clearChangeReview,
|
||||
]);
|
||||
|
||||
// Reset initial scroll flag when initialFilePath changes
|
||||
useEffect(() => {
|
||||
initialScrollDoneRef.current = false;
|
||||
}, [initialFilePath]);
|
||||
|
||||
// Scroll to initialFilePath once data is loaded
|
||||
useEffect(() => {
|
||||
if (!activeChangeSet || !initialFilePath || initialScrollDoneRef.current) return;
|
||||
const hasFile = activeChangeSet.files.some((f) => f.filePath === initialFilePath);
|
||||
if (!hasFile) return;
|
||||
initialScrollDoneRef.current = true;
|
||||
requestAnimationFrame(() => {
|
||||
requestAnimationFrame(() => scrollToFile(initialFilePath));
|
||||
});
|
||||
}, [activeChangeSet, initialFilePath, scrollToFile]);
|
||||
|
||||
// Escape to close
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue