Fix loss of tree node state when switching views
This commit fixes an issue where the check state of categories was lost when toggling between card and tree views. This is solved by immediately emitting node state changes for all nodes. This ensures consistent view transitions without any loss of node state information. Furthermore, this commit includes added unit tests for the modified code sections.
This commit is contained in:
32
tests/unit/shared/Stubs/UseCurrentTreeNodesStub.ts
Normal file
32
tests/unit/shared/Stubs/UseCurrentTreeNodesStub.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
WatchSource, readonly, shallowRef, triggerRef,
|
||||
} from 'vue';
|
||||
import { TreeRoot } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/TreeRoot';
|
||||
import { useCurrentTreeNodes } from '@/presentation/components/Scripts/View/Tree/TreeView/UseCurrentTreeNodes';
|
||||
import { QueryableNodes } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/NodeCollection/Query/QueryableNodes';
|
||||
import { QueryableNodesStub } from './QueryableNodesStub';
|
||||
|
||||
export class UseCurrentTreeNodesStub {
|
||||
public treeWatcher: WatchSource<TreeRoot> | undefined;
|
||||
|
||||
private nodes = shallowRef<QueryableNodes>(new QueryableNodesStub());
|
||||
|
||||
public withQueryableNodes(nodes: QueryableNodes): this {
|
||||
this.nodes.value = nodes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public triggerNewNodes(nodes: QueryableNodes) {
|
||||
this.nodes.value = nodes;
|
||||
triggerRef(this.nodes);
|
||||
}
|
||||
|
||||
public get(): typeof useCurrentTreeNodes {
|
||||
return (treeWatcher: WatchSource<TreeRoot>) => {
|
||||
this.treeWatcher = treeWatcher;
|
||||
return {
|
||||
nodes: readonly(this.nodes),
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user