fix(files): guard pending navigation (#1172)
* fix(files): guard pending navigation * fix(files): avoid pending navigation re-entry --------- Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
f524880c94
commit
15f2179274
@@ -2138,9 +2138,10 @@ export const FilesView: React.FC<FilesViewProps> = ({ mode = 'full' }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selectedFile?.path !== targetPath) {
|
if (selectedFile?.path !== targetPath) {
|
||||||
if (selectedPath !== targetPath) {
|
if (confirmDiscardOpen) {
|
||||||
setSelectedPath(root, targetPath);
|
return;
|
||||||
}
|
}
|
||||||
|
void handleSelectFile(toFileNode(targetPath));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2213,19 +2214,20 @@ export const FilesView: React.FC<FilesViewProps> = ({ mode = 'full' }) => {
|
|||||||
pendingNavigationCycleRef.current = { key: '', attempts: 0 };
|
pendingNavigationCycleRef.current = { key: '', attempts: 0 };
|
||||||
}, [
|
}, [
|
||||||
canEdit,
|
canEdit,
|
||||||
|
confirmDiscardOpen,
|
||||||
draftContent,
|
draftContent,
|
||||||
editorViewReadyNonce,
|
editorViewReadyNonce,
|
||||||
fileError,
|
fileError,
|
||||||
fileLoading,
|
fileLoading,
|
||||||
isSelectedImage,
|
isSelectedImage,
|
||||||
loadedFilePath,
|
loadedFilePath,
|
||||||
|
handleSelectFile,
|
||||||
pendingFileNavigation,
|
pendingFileNavigation,
|
||||||
root,
|
root,
|
||||||
selectedFile?.path,
|
selectedFile?.path,
|
||||||
selectedPath,
|
|
||||||
setPendingFileNavigation,
|
setPendingFileNavigation,
|
||||||
setSelectedPath,
|
|
||||||
textViewMode,
|
textViewMode,
|
||||||
|
toFileNode,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@@ -2240,9 +2242,10 @@ export const FilesView: React.FC<FilesViewProps> = ({ mode = 'full' }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selectedFile?.path !== targetPath) {
|
if (selectedFile?.path !== targetPath) {
|
||||||
if (selectedPath !== targetPath) {
|
if (confirmDiscardOpen) {
|
||||||
setSelectedPath(root, targetPath);
|
return;
|
||||||
}
|
}
|
||||||
|
void handleSelectFile(toFileNode(targetPath));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2261,17 +2264,18 @@ export const FilesView: React.FC<FilesViewProps> = ({ mode = 'full' }) => {
|
|||||||
setPendingFileFocusPath(null);
|
setPendingFileFocusPath(null);
|
||||||
}, [
|
}, [
|
||||||
canEdit,
|
canEdit,
|
||||||
|
confirmDiscardOpen,
|
||||||
fileError,
|
fileError,
|
||||||
fileLoading,
|
fileLoading,
|
||||||
|
handleSelectFile,
|
||||||
isSelectedImage,
|
isSelectedImage,
|
||||||
loadedFilePath,
|
loadedFilePath,
|
||||||
pendingFileFocusPath,
|
pendingFileFocusPath,
|
||||||
root,
|
root,
|
||||||
selectedFile?.path,
|
selectedFile?.path,
|
||||||
selectedPath,
|
|
||||||
setPendingFileFocusPath,
|
setPendingFileFocusPath,
|
||||||
setSelectedPath,
|
|
||||||
textViewMode,
|
textViewMode,
|
||||||
|
toFileNode,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const nudgeEditorSelectionAboveKeyboard = React.useCallback((view: EditorView | null) => {
|
const nudgeEditorSelectionAboveKeyboard = React.useCallback((view: EditorView | null) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user