Skip to content

Commit

Permalink
Prefer .present, only show new div when content exists
Browse files Browse the repository at this point in the history
  • Loading branch information
owenniblock committed Sep 13, 2024
1 parent b10b725 commit b80c16a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/components/primer/alpha/select_panel.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
)) do %>
<div data-hide-on-error>
<%= render Primer::Beta::Spinner.new(aria: { label: @loading_label, describedby: @loading_description_id }, data: { target: "select-panel.bodySpinner" }) %>
<div id="<%= @loading_description_id %>" aria-hidden="true"><%= @loading_description %></div>
<% if @loading_description.present? %>
<div id="<%= @loading_description_id %>" aria-hidden="true"><%= @loading_description %></div>
<% end %>
</div>
<div data-show-on-error hidden data-target="select-panel.fragmentErrorElement">
<% if preload_error_content? %>
Expand Down
2 changes: 1 addition & 1 deletion app/components/primer/alpha/select_panel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def initialize(
@dynamic_aria_label_prefix = dynamic_aria_label_prefix
@loading_label = loading_label
@loading_description_id = nil
unless loading_description.nil?
if loading_description.present?
@loading_description_id = "#{@panel_id}-loading-description"
end
@loading_description = loading_description
Expand Down

0 comments on commit b80c16a

Please sign in to comment.