Skip to content

Commit

Permalink
fix for search mode and debounce input with patternslib util
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Oct 10, 2024
1 parent 8d8c110 commit c569cd4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
21 changes: 10 additions & 11 deletions src/pat/contentbrowser/src/ContentBrowser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@
const possibleFocusEls = [
...document.querySelectorAll(".levelColumn .inPath"), // previously selected folder
...document.querySelectorAll(".levelColumn .selectedItem"), // previously selected item
document.querySelector(".levelColumn .contentItem"), // default first item
];
if(!possibleFocusEls.length && document.querySelector(".levelColumn .contentItem")) {
possibleFocusEls.push(document.querySelector(".levelColumn .contentItem"));
}
if (possibleFocusEls.length) {
keyboardNavInitialized = true;
possibleFocusEls[0].focus();
Expand Down Expand Up @@ -310,18 +312,12 @@
}
function itemInPath(item) {
return $currentPath.indexOf(item.path) != -1;
return $config.mode == "browse" && $currentPath.indexOf(item.path) != -1;
}
function filterItems() {
let timeoutId;
if (timeoutId) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
contentItems.get({ path: $currentPath, searchTerm: this.value });
}, 300);
}
const filterItems = utils.debounce((e) => {
contentItems.get({ path: $currentPath, searchTerm: e.target.value });
}, 300);
function loadMore(node) {
const observer = new IntersectionObserver(
Expand Down Expand Up @@ -506,6 +502,9 @@
}}
/>
{item.Title}
{#if $config.mode == "search"}
<br><span class="small">{item.path}</span>
{/if}
</div>
{/if}
{#if item.is_folderish && $config.mode == "browse"}
Expand Down
4 changes: 2 additions & 2 deletions src/pat/contentbrowser/src/ContentStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default function (config, pathCache) {
page: page,
};
if (searchTerm) {
if (searchTerm.length < 3) {
if (searchTerm.length < 2) {
// minimum length of search term
return;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ export default function (config, pathCache) {
page = 1,
}) => {
if (config.mode === "search") {
await search(searchTerm, page)
await search(searchTerm, page);
} else if (loadMorePath) {
const pC = get(pathCache);
if (!(loadMorePath in pC)) {
Expand Down
2 changes: 1 addition & 1 deletion src/pat/contentbrowser/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function request({
},
],
};
if (selectableTypes) {
if (selectableTypes.length) {
vocabQuery.criteria.push({
i: "portal_type",
o: "plone.app.querystring.operation.list.contains",
Expand Down

0 comments on commit c569cd4

Please sign in to comment.