FIX: Do not duplicate admin sidebar plugin links (#25780)

When hiding/showing the sidebar, as is the case on mobile
and using the toggle in the top left on desktop, we delete
and recreate the ember component on the page. This causes
the `sections` for each sidebar panel to get re-evaluated
every time.

For the admin sidebar, this means that we were constantly
re-adding the plugin links to the sidebar, causing duplication.
This can be fixed by just adding @cached to the getter for
sections.
This commit is contained in:
Martin Brennan
2024-02-21 12:58:31 +10:00
committed by GitHub
parent 533b91dec6
commit 95014e9ab8
3 changed files with 21 additions and 3 deletions
@@ -14,4 +14,12 @@ describe "Admin Revamp | Sidebar Navigation | Plugin Links", type: :system do
visit("/admin")
expect(sidebar).to have_section_link("Chat", href: "/admin/plugins/chat")
end
it "does not duplicate links to enabled plugin admin routes when showing and hiding sidebar" do
visit("/admin")
expect(sidebar).to have_section_link("Chat", href: "/admin/plugins/chat", count: 1)
find(".header-sidebar-toggle").click
find(".header-sidebar-toggle").click
expect(sidebar).to have_section_link("Chat", href: "/admin/plugins/chat", count: 1)
end
end