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 (selectedPath !== targetPath) {
|
||||
setSelectedPath(root, targetPath);
|
||||
if (confirmDiscardOpen) {
|
||||
return;
|
||||
}
|
||||
void handleSelectFile(toFileNode(targetPath));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2213,19 +2214,20 @@ export const FilesView: React.FC<FilesViewProps> = ({ mode = 'full' }) => {
|
||||
pendingNavigationCycleRef.current = { key: '', attempts: 0 };
|
||||
}, [
|
||||
canEdit,
|
||||
confirmDiscardOpen,
|
||||
draftContent,
|
||||
editorViewReadyNonce,
|
||||
fileError,
|
||||
fileLoading,
|
||||
isSelectedImage,
|
||||
loadedFilePath,
|
||||
handleSelectFile,
|
||||
pendingFileNavigation,
|
||||
root,
|
||||
selectedFile?.path,
|
||||
selectedPath,
|
||||
setPendingFileNavigation,
|
||||
setSelectedPath,
|
||||
textViewMode,
|
||||
toFileNode,
|
||||
]);
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -2240,9 +2242,10 @@ export const FilesView: React.FC<FilesViewProps> = ({ mode = 'full' }) => {
|
||||
}
|
||||
|
||||
if (selectedFile?.path !== targetPath) {
|
||||
if (selectedPath !== targetPath) {
|
||||
setSelectedPath(root, targetPath);
|
||||
if (confirmDiscardOpen) {
|
||||
return;
|
||||
}
|
||||
void handleSelectFile(toFileNode(targetPath));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2261,17 +2264,18 @@ export const FilesView: React.FC<FilesViewProps> = ({ mode = 'full' }) => {
|
||||
setPendingFileFocusPath(null);
|
||||
}, [
|
||||
canEdit,
|
||||
confirmDiscardOpen,
|
||||
fileError,
|
||||
fileLoading,
|
||||
handleSelectFile,
|
||||
isSelectedImage,
|
||||
loadedFilePath,
|
||||
pendingFileFocusPath,
|
||||
root,
|
||||
selectedFile?.path,
|
||||
selectedPath,
|
||||
setPendingFileFocusPath,
|
||||
setSelectedPath,
|
||||
textViewMode,
|
||||
toFileNode,
|
||||
]);
|
||||
|
||||
const nudgeEditorSelectionAboveKeyboard = React.useCallback((view: EditorView | null) => {
|
||||
|
||||
Reference in New Issue
Block a user