Skip to content

Commit

Permalink
Merge pull request #1439 from plone/contentbrowser-initialpath-fix
Browse files Browse the repository at this point in the history
Fix selecting current path when opening `pat-contentbrowser` initially
  • Loading branch information
petschki authored Feb 21, 2025
2 parents 81ae4f4 + 5e45332 commit 824fa38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/pat/contentbrowser/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,24 @@
const currentPath = getContext("currentPath");
if (!$currentPath) {
if(basePath || rootPath) {
if (basePath || rootPath) {
// if root path is not above base path we start at rootPath
$currentPath = basePath.indexOf(rootPath) != 0 ? rootPath : basePath;
if (
rootPath &&
$currentPath != rootPath &&
$currentPath.indexOf(rootPath) == 0
) {
// remove rootPath from $currentPath
$currentPath = $currentPath.replace(rootPath, "");
}
} else {
// no path available. try to determine path from vocabularyUrl
const vocabPath = new URL(vocabularyUrl).pathname.split("/");
rootPath = contextPath = $currentPath = vocabPath.slice(0, vocabPath.length - 1).join("/") || "/";
rootPath =
contextPath =
$currentPath =
vocabPath.slice(0, vocabPath.length - 1).join("/") || "/";
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/pat/contentbrowser/src/ContentBrowser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
class={gridView
? "grid-preview"
: "item-title"}
title="{item.portal_type}: {item.Title}"
title="{item.path}: {item.Title}"
>
{#if gridView && item.getIcon}
<img
Expand Down Expand Up @@ -834,7 +834,7 @@
}
.levelToolbar {
width: 100%;
height: 2.5rem;
min-height: 2.5rem;
display: flex;
justify-content: space-between;
white-space: nowrap;
Expand Down

0 comments on commit 824fa38

Please sign in to comment.