mirror of
https://github.com/go-gitea/gitea.git
synced 2026-06-17 22:36:28 +02:00
fix(file-tree): handle submodule links and missing view container
Prevent tree view navigation from intercepting submodule entries so the browser can follow external repository links normally. Also guard against a missing `.repo-view-content` container before updating partial page content to avoid runtime errors.
This commit is contained in:
parent
60f66a9bfd
commit
d6353c2da1
@ -32,6 +32,8 @@ const onItemClick = (e: MouseEvent) => {
|
||||
// - the user didn't press any special key like "Ctrl+Click" (which may have custom browser behavior)
|
||||
// - the editor/commit form isn't dirty (a full page reload shows a confirmation dialog if the form contains unsaved changes)
|
||||
if (!isPlainClick(e) || shouldTriggerAreYouSure()) return;
|
||||
// submodules (commit entry mode) point to external repos, let the browser handle navigation normally
|
||||
if (props.item.entryMode === 'commit') return;
|
||||
e.preventDefault();
|
||||
if (props.item.entryMode === 'tree') doLoadChildren();
|
||||
store.navigateTreeView(props.item.fullPath);
|
||||
|
||||
@ -41,7 +41,8 @@ export function createViewFileTreeStore(props: {repoLink: string, treePath: stri
|
||||
const u = new URL(url, window.origin);
|
||||
u.searchParams.set('only_content', 'true');
|
||||
const response = await GET(u.href);
|
||||
const elViewContent = document.querySelector('.repo-view-content')!;
|
||||
const elViewContent = document.querySelector('.repo-view-content');
|
||||
if (!elViewContent) return;
|
||||
elViewContent.innerHTML = await response.text();
|
||||
const elViewContentData = elViewContent.querySelector('.repo-view-content-data');
|
||||
if (!elViewContentData) return; // if error occurs, there is no such element
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user