fix: Fix the issues with the new sidebar (#10348)

Co-authored-by: Pranav <pranavrajs@gmail.com>
This commit is contained in:
Shivam Mishra
2024-10-29 09:11:43 +05:30
committed by GitHub
parent 6df2d76c1e
commit 7ba6c1d87d
2 changed files with 20 additions and 13 deletions

View File

@@ -28,11 +28,12 @@ const {
const parentEl = ref(null);
const locateLastChild = () => {
parentEl.value?.querySelectorAll('.child-item').forEach((child, index) => {
if (index === parentEl.value.querySelectorAll('.child-item').length - 1) {
child.classList.add('last-child-item');
}
const locateLastChild = async () => {
const children = parentEl.value?.querySelectorAll('.child-item');
if (!children) return;
children.forEach((child, index) => {
child.classList.toggle('last-child-item', index === children.length - 1);
});
};
@@ -103,7 +104,7 @@ const toggleTrigger = () => {
setExpandedItem(props.name);
};
watch(expandedItem, locateLastChild, {
watch([expandedItem, accessibleItems], locateLastChild, {
immediate: true,
});
</script>