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';
|
mode: 'agent' | 'task';
|
||||||
memberName?: string;
|
memberName?: string;
|
||||||
taskId?: string;
|
taskId?: string;
|
||||||
|
initialFilePath?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isTaskChangeSetV2(cs: { teamName: string }): cs is TaskChangeSetV2 {
|
function isTaskChangeSetV2(cs: { teamName: string }): cs is TaskChangeSetV2 {
|
||||||
|
|
@ -42,6 +43,7 @@ export const ChangeReviewDialog = ({
|
||||||
mode,
|
mode,
|
||||||
memberName,
|
memberName,
|
||||||
taskId,
|
taskId,
|
||||||
|
initialFilePath,
|
||||||
}: ChangeReviewDialogProps): React.ReactElement | null => {
|
}: ChangeReviewDialogProps): React.ReactElement | null => {
|
||||||
const {
|
const {
|
||||||
activeChangeSet,
|
activeChangeSet,
|
||||||
|
|
@ -92,6 +94,9 @@ export const ChangeReviewDialog = ({
|
||||||
: null;
|
: null;
|
||||||
}, [activeFilePath]);
|
}, [activeFilePath]);
|
||||||
|
|
||||||
|
// One-shot scroll-to-file ref (for initialFilePath)
|
||||||
|
const initialScrollDoneRef = useRef(false);
|
||||||
|
|
||||||
// Continuous scroll navigation
|
// Continuous scroll navigation
|
||||||
const { scrollToFile, isProgrammaticScroll } = useContinuousScrollNav({
|
const { scrollToFile, isProgrammaticScroll } = useContinuousScrollNav({
|
||||||
scrollContainerRef,
|
scrollContainerRef,
|
||||||
|
|
@ -255,6 +260,22 @@ export const ChangeReviewDialog = ({
|
||||||
clearChangeReview,
|
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
|
// Escape to close
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue