Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only get id once. #74

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<li class="<%= li_class %>" data-controller="<%= controller_name %>" role="treeitem">
<% ul_id = "b-h-#{SecureRandom.alphanumeric(10)}" %>
<%= helpers.facet_toggle_button(field_name, id, ul_id) if subset.any? %>
<% if item.nil? %>
<%= key %>
Expand Down
6 changes: 4 additions & 2 deletions app/components/blacklight/hierarchy/facet_field_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def initialize(field_name:, tree:, key:)
@field_name = field_name
@tree = tree
@key = key
@id = SecureRandom.uuid
end

attr_reader :field_name, :tree, :key, :id
Expand All @@ -24,7 +23,6 @@ def controller_name
subset.empty? ? '' : 'b-h-collapsible'
end


def item
tree[:_]
end
Expand All @@ -33,6 +31,10 @@ def qfacet_selected?
config = helpers.facet_configuration_for_field(field_name)
helpers.search_state.filter(config).include?(item.qvalue)
end

def ul_id
@ul_id ||= "b-h-#{SecureRandom.alphanumeric(10)}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where was this called more than one time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ul_id is used in L2 and L12 of app/components/blacklight/hierarchy/facet_field_component.html.erb

Previously, SecureRandom.alphanumeric(10) was called in facet_field_component.html.erb and facet_field_component.rb

end
end
end
end