From 6e6c5a2f021df7fcf2f0d40e7aba8e83a0f146e9 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 31 Oct 2024 09:39:18 +0530 Subject: [PATCH] refactor: use css only last item detection (#10363) The last item in the sidebar top level group has an indicator specified, the problem in our case is that the structure can be nested and have sub groups. So selecting the last item correctly can be tricky. Previous implementation relied on the using DOM queries to find the last item from a flat list of children, it would trigger on a `watch`. This was error-prone as well as non idiomatic. The new approach is CSS-only and reduces the unnecessary compute required. Codepen for reference: https://codepen.io/scmmishra/pen/yLmKNLW --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> --- .../components-next/sidebar/SidebarGroup.vue | 74 ++++++++++++++----- .../sidebar/SidebarGroupLeaf.vue | 41 ---------- 2 files changed, 57 insertions(+), 58 deletions(-) diff --git a/app/javascript/dashboard/components-next/sidebar/SidebarGroup.vue b/app/javascript/dashboard/components-next/sidebar/SidebarGroup.vue index f4ffcd0cd..89d99d402 100644 --- a/app/javascript/dashboard/components-next/sidebar/SidebarGroup.vue +++ b/app/javascript/dashboard/components-next/sidebar/SidebarGroup.vue @@ -1,5 +1,5 @@ @@ -132,7 +117,6 @@ watch([expandedItem, accessibleItems], locateLastChild, {