Skip to content

Commit

Permalink
Merge pull request #806 from sul-dlss/fix-search-button
Browse files Browse the repository at this point in the history
Use local component for search button
  • Loading branch information
marlo-longley authored Oct 8, 2024
2 parents 1740be5 + 33af2cc commit dc70c68
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/components/arclight/search_bar_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
<% end if append? %>
<% c.with_search_button do %>
<%= search_button %>
<% end if respond_to?(:search_button?) && search_button? # only BL8 has this option %>
<%= render SearchButtonComponent.new(id: "#{@prefix}search", text: scoped_t('submit')) %>
<% end %>
<% end %>
4 changes: 4 additions & 0 deletions app/components/landing_page_search_bar_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ def initialize(**kwargs)
# Default to grouping search results by collection.
@params = @params.merge(@params, group: true)
end

def search_button
render SearchButtonComponent.new(id: "#{@prefix}search", text: scoped_t('submit'))
end
end
12 changes: 12 additions & 0 deletions app/components/search_button_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

# Subclasses Blacklight's SearchButtonComponent so we can set the
# button text to visually-hidden at all screen sizes
class SearchButtonComponent < Blacklight::SearchButtonComponent
def call
tag.button(class: 'btn btn-primary search-btn', type: 'submit', id: @id) do
tag.span(@text, class: 'visually-hidden submit-search-text') +
render(Blacklight::Icons::SearchComponent.new)
end
end
end

0 comments on commit dc70c68

Please sign in to comment.