Improve active class assignment in sidebar links (#450)

* Fix active class assignment in sidebar links

* Revert "Fix active class assignment in sidebar links"

This reverts commit 55924f32db9f5a0c0948d19b3af79d729feb6ef7.

* Update sidebar_link_to helper to correctly assign active class for nested routes

---------

Co-authored-by: Zach Gollwitzer <zach.gollwitzer@gmail.com>
This commit is contained in:
Mattia
2024-02-14 12:55:23 +00:00
committed by GitHub
parent 101a5ee0c5
commit 0490fda465

View File

@@ -34,7 +34,7 @@ module ApplicationHelper
hover_class_names = [ "hover:bg-white", "hover:border-alpha-black-50", "hover:text-gray-900", "hover:shadow-xs" ]
current_page_class_names = [ "bg-white", "border-alpha-black-50", "text-gray-900", "shadow-xs" ]
link_class_names = if current_page?(path)
link_class_names = if current_page?(path) || (request.path.start_with?(path) && path != "/")
base_class_names.delete("border-transparent")
base_class_names + hover_class_names + current_page_class_names
else