@@ -67,27 +67,36 @@ def navbar_item(text, url = nil, list_item_options = nil, link_options = nil, &b
6767HTML
6868 end
6969
70- def navbar_dropdown ( text , target = '' , list_item_options = { } , link_options = { } , ul_options = { } , &block )
70+ def navbar_dropdown ( text , id = '' , list_item_options = { } , link_options = { } , &block )
7171 list_item_options , link_options = list_item_options . dup , link_options . dup
7272 list_item_options [ :class ] = [ list_item_options [ :class ] , 'nav-item' , 'dropdown' ] . compact . join ( ' ' )
7373 list_item_attributes = attributes_for_tag ( list_item_options )
7474 link_options [ :class ] = [ link_options [ :class ] , 'nav-link' , 'dropdown-toggle' ] . compact . join ( ' ' )
75- target ||= "navbarDropdownMenuLink#{ text } "
75+ id ||= "navbarDropdownMenuLink#{ text } "
7676 link_attributes = attributes_for_tag ( link_options )
77- ul_options [ :class ] = [ ul_options [ :class ] , 'nav' ] . compact . join ( ' ' )
78- ul_attributes = attributes_for_tag ( ul_options )
7977 prepare_html <<-HTML . chomp!
8078< li #{ list_item_attributes } >
81- < a href ="# " data-toggle ="dropdown " data-target ="# #{ target } "#{ link_attributes } > #{ text } < b class ="caret "> </ b > </ a>
82- < div class ="collapse " id ="#{ target } ">
83- < ul #{ ul_attributes } >
84- #{ capture ( &block ) if block_given? }
85- </ ul>
79+ < a href ="# " data-toggle ="dropdown " id ="# #{ id } " aria-haspopup="true" aria-expanded="false" role="button" #{ link_attributes } > #{ text } </ a>
80+ < div class ="dropdown-menu " aria-labelledby ="#{ id } ">
81+ #{ capture ( &block ) if block_given? }
8682 </ div>
8783</ li>
8884HTML
8985 end
9086
87+ def navbar_dropdown_item ( text , url = '#' , link_options = { } , &block )
88+ link_options = link_options . dup
89+ link_options [ :class ] = [ link_options [ :class ] , 'dropdown-item' ] . compact
90+ link_options [ :class ] << 'active' if current_url_or_sub_url? ( url )
91+ link_options [ :class ] = link_options [ :class ] . join ( ' ' )
92+ link_attributes = attributes_for_tag ( link_options )
93+ prepare_html <<~HTML . chomp!
94+ < a href ="#{ url } "#{ link_attributes } >
95+ #{ text }
96+ </ a>
97+ HTML
98+ end
99+
91100 private
92101
93102 def container ( &block )
0 commit comments