Skip to content

Commit

Permalink
Add primevue 4.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Oct 7, 2024
1 parent 9815002 commit c9f1544
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions arches_lingo/src/arches_lingo/components/tree/ConceptTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ const expandPathsToFilterResults = (newFilterValue: string) => {
nextFilterChangeNeedsExpandAll.value = false;
};
const getInputElement = () => {
function getInputElement() {
if (treeDOMRef.value !== null) {
return treeDOMRef.value.$el.ownerDocument.querySelector(
'input[data-pc-name="pcfilter"]',
'input[data-pc-name="pcfilterinput"]',
) as HTMLInputElement;
}
};
}
const restoreFocusToInput = () => {
// The current implementation of collapsing all nodes when
Expand All @@ -181,25 +181,9 @@ const snoopOnFilterValue = () => {
}
};
const filterCallbackWrapped = computed(() => {
// Access some hidden functionality of the PrimeVue <Tree> to make
// filter lookups lazy, that is, making use of the current state of the
// label values and the selected language when doing the filtering.
// "Hidden", because we need to violate the type of filter-by, which
// should be a string. If we abuse it to be something that returns
// a 1-element array containing a getter when split() is called on it,
// that getter can return the best label to filter against.
return {
split: () => {
return [
(node: TreeNode) => {
return bestLabel(node.data, selectedLanguage.value.code)
.value;
},
];
},
};
});
function lazyLabelLookup(node: TreeNode) {
return bestLabel(node.data, selectedLanguage.value.code).value;
}
const updateSelectedAndExpanded = (node: TreeNode) => {
setDisplayedRow(node.data);
Expand Down Expand Up @@ -252,7 +236,7 @@ await initializeTree();
v-model:expanded-keys="expandedKeys"
:value="tree"
:filter="true"
:filter-by="filterCallbackWrapped as unknown as string"
:filter-by="lazyLabelLookup"
filter-mode="lenient"
:filter-placeholder="$gettext('Find')"
selection-mode="single"
Expand Down

0 comments on commit c9f1544

Please sign in to comment.