Skip to content

Commit

Permalink
fix(HeadlineEditor): Use Tooltip
Browse files Browse the repository at this point in the history
Instead of title - that has lots of accessibility issues -
we use our established Shoelace Tooltip.
  • Loading branch information
tvdeyen committed Apr 10, 2024
1 parent bd056bd commit a6e6675
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
25 changes: 14 additions & 11 deletions app/views/alchemy/ingredients/_headline_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@
<% end %>

<div class="input-addon right<%= " second" if has_size_select %>">
<%= f.select :level,
options_for_select(headline_editor.level_options, headline_editor.level),
{},
{
class: "custom-select",
title: f.object.class.human_attribute_name(:level),
disabled: !has_level_select
} %>
<sl-tooltip content="<%= f.object.class.human_attribute_name(:level) %>">
<%= f.select :level,
options_for_select(headline_editor.level_options, headline_editor.level),
{},
{
class: "custom-select",
disabled: !has_level_select
} %>
</sl-tooltip>
</div>

<% if has_size_select %>
<div class="input-addon right">
<%= f.select :size, options_for_select(headline_editor.size_options, headline_editor.size),
{},
{ class: "custom-select", title: f.object.class.human_attribute_name(:size) } %>
<sl-tooltip content="<%= f.object.class.human_attribute_name(:size) %>">
<%= f.select :size, options_for_select(headline_editor.size_options, headline_editor.size),
{},
{ class: "custom-select" } %>
</sl-tooltip>
</div>
<% end %>
<% end %>
Expand Down
8 changes: 8 additions & 0 deletions spec/views/alchemy/ingredients/headline_editor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
is_expected.to have_selector("select[name='element[ingredients_attributes][0][level]']")
end

it "renders a tooltip" do
is_expected.to have_selector("sl-tooltip[content='Level']")
end

context "when only one level is given" do
let(:settings) do
{levels: [1]}
Expand All @@ -60,6 +64,10 @@
it "renders a size select" do
is_expected.to have_selector("select[name='element[ingredients_attributes][0][size]']")
end

it "renders a tooltip" do
is_expected.to have_selector("sl-tooltip[content='Size']")
end
end

context "with settings anchor set to true" do
Expand Down

0 comments on commit a6e6675

Please sign in to comment.